Didart

Big Factorial

Oct 27th, 2021
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. import java.math.BigInteger;
  2. import java.util.Scanner;
  3.  
  4. public class BigFactorial {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         int n = Integer.parseInt(scanner.nextLine());
  9.  
  10.         BigInteger bigNum = new BigInteger(String.valueOf(1));
  11.        
  12.         for (int i = 1; i <= n; i++) {
  13.             bigNum = bigNum.multiply(BigInteger.valueOf(i));
  14.         }
  15.         System.out.println(bigNum);
  16.     }
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment