In this HackerRank Day 5: Loops problem solution Given an integer, n, print its first 10 multiples. Each multiple n x i (where 1 <= i <= 10 ) should be printed on a new line in the form: n x i = result.

HackerRank Day 5: Loops problem solution

Problem solution in Python programming.

#!/bin/python3

import sys


N = int(input().strip())

for x in range(1,11):
    print("%d x %d = %d" % (N,x,N*x))


Problem solution in Java programming.

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        for(int i =1; i<=10; i++){
            System.out.println(String.format("%d x %d = %d", N, i, N*i ) );
        }
    }
}




Problem solution in C++ programming.

#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;
    
    int endOfRange = 10;
    
    for(int i = 1 ; i <= endOfRange ; i++){
        
        cout << N <<" x "<<i<<" = "<< N*i <<endl;
    }
    return 0;
}



Problem solution in C programming.

#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; 
    scanf("%d",&N);
    int i;
    for(i=1;i<=10;i++){
        printf("%d x %d = %d\n", N, i, N*i);
    }
    return 0;
}



Problem solution in Javascript programming.

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++];
}

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

function main() {
    var N = parseInt(readLine()),
        i = 1;
    
    while (i <=10) {
        console.log(`${N} x ${i} = ${N*i}`);
        i++;
    }
}