Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Solution {
- private static void printFactorial(int x) {
- long res = 1;
- for(long i = x; i > 1; i--) {
- res *= i;
- }
- System.out.println("# " + x + "! = " + res);
- }
- public static void main(String[] args) {
- try(Scanner sc = new Scanner(System.in)) {
- System.out.print("使用回数を指定: ");
- int T = sc.nextInt();
- while(T-- > 0) {
- System.out.print("値を入力: ");
- int N = sc.nextInt();
- printFactorial(N);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement