Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Solution {
  4.  
  5. private static void printFactorial(int x) {
  6. long res = 1;
  7. for(long i = x; i > 1; i--) {
  8. res *= i;
  9. }
  10. System.out.println("# " + x + "! = " + res);
  11. }
  12.  
  13. public static void main(String[] args) {
  14. try(Scanner sc = new Scanner(System.in)) {
  15. System.out.print("使用回数を指定: ");
  16. int T = sc.nextInt();
  17. while(T-- > 0) {
  18. System.out.print("値を入力: ");
  19. int N = sc.nextInt();
  20. printFactorial(N);
  21. }
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement