Loops Problem solution 30 days of code HackerRank

Input Format
A single integer, .
Constraints
Output Format
Print  lines of output; each line  (where ) contains the  of  in the form:
n x i = result.
Loops Problem solution 30 days of code HackerRank

Problem solution in Python programming language.

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

Problem solution in Ruby programming language.

N = gets.strip.to_i
(1..10).each do |i|
    print N," x ", i, " = ", N*i
    print "\n"
end

Problem solution in Java programming language.

import java.util.*;

public class Solution {

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

Post a Comment

0 Comments