Skip to content
Programmingoneonone
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone
Programmingoneonone

Learn everything about programming

Hackerrank Day 5 loops 30 days of code solution

YASH PAL, 31 July 202413 October 2025

In this HackerRank Day 5 loops 30 days of code problem solution we need to develop a program that can read an integer input and then print the multiplication table on the output screen.

Objective
In this challenge, we will use loops to do some math.

Task
Given an integer, n, print its first 10 multiples. Each multiple n x i (where 2 <= i <= 10 ) should be printed on a new line in the form: n x i = result.

Example
n=3

The printout should look like this:
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
3 x 6 = 18
3 x 7 = 21
3 x 8 = 24
3 x 9 = 27
3 x 10 = 30

Input Format
A single integer, n.

Constraints
2 <= n <= 20

Output Format
Print 10 lines of output; each line i (where 1<=i<=10) contains the result of nxi in the form:
n x i = result.

Problem solution in Python 2.

#!/bin/python

import sys


N = int(raw_input().strip())
for i in range(10):
    print "{} x {} = {}".format(N, i+1, N * (i + 1))

Problem solution in Python 3.

#!/bin/python3

import math
import os
import random
import re
import sys



if __name__ == '__main__':
    n = int(input())
    
    for i in range(1,11):
        s = n * i
        print(n,"x",i,"=",s)

Problem solution in java

import java.io.*;
import java.util.*;

public class Solution {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=1;i<11;i++){
            int ans = n * i;
            System.out.println(n + " x " + i + " = " + ans);
        }
    }
}

Problem solution in C++

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;


int main(){
    int N;
    cin >> N;
    for (int i=1;i<=10;i++){
        cout<<N<<" x "<<i<<" = "<<N*i<<endl;
    }
    return 0;
}

Problem solution in c.

#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
    int N,i; 
    scanf("%d",&N);
    if(N>=2 && N<= 20){
        for(i=1;i<=10;i++){
            printf("%d x %d = %d n",N,i,(N*i));
        }
    }
    return 0;
}

Problem solution in Javascript.

process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

function printdis(N)
{
    var i, temp;
    for (i = 1; i <= 10; i++)
        {
            temp = N * i;
            console.log(N + " x " + i + " = " + temp);
        }
}

/////////////// ignore above this line ////////////////////

function main() {
    var N = parseInt(readLine());
    printdis(N);

}

Also, read

  • HackerRank Day 6 Let’s Review 30 days of code problem solution
30 days of code coding problems solutions HackerRank

Post navigation

Previous post
Next post

Are you a student and stuck with your career or worried about real-time things, and don't know how to manage your learning phase? Which profession to choose? and how to learn new things according to your goal, and land a dream job. Then this might help to you.

Hi My name is YASH PAL, founder of this Blog and a Senior Software engineer with 5+ years of Industry experience. I personally helped 40+ students to make a clear goal in their professional lives. Just book a one-on-one personal call with me for 30 minutes for 300 Rupees. Ask all your doubts and questions related to your career to set a clear roadmap for your professional life.

Book session - https://wa.me/qr/JQ2LAS7AASE2M1

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes