Advertisement
Lyubohd

03. Big Factorial

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