Java Loops I - HackerRank Solutions 2020

Java Loops I - HackerRank Solutions 2020

Java Loops I - HackerRank Solutions 2020
Friday, 4 September 2020

In this challenge, we're going to use loops to help us do some simple math.

 

Task

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

 

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. 



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

public class Solution {



    private static final Scanner scanner = new Scanner(System.in);

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

Java Loops I - HackerRank Solutions 2020
4/ 5
Oleh