Lyubohd

03. Big Factorial

Jun 23rd, 2021
631
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
RAW Paste Data