[ Java ][HackerRank] 30 Days of code Day 5


Day 5 : Loops


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

  • 2<= n <= 20

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) {
        int n = scanner.nextInt();
        scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

        for(int i=1; i<=10; i++){
            System.out.println(n + " x " + i +" = "+ n*i);

        }
        scanner.close();
    }
}


기본적인 for문 문제.




© 2018. by sora

Powered by sora