Skip to content

Commit

Permalink
Add extra long factorials java solution
Browse files Browse the repository at this point in the history
  • Loading branch information
prasadhonrao committed Jun 21, 2019
1 parent 871106f commit 9201866
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Solution {

// Complete the extraLongFactorials function below.
static void extraLongFactorials(int n) {
BigInteger factorial = new BigInteger("1");
while (n > 1) {
factorial = factorial.multiply(BigInteger.valueOf(n));
n--;
}
System.out.println(factorial);
}

private static final Scanner scanner = new Scanner(System.in);

public static void main(String[] args) {
int n = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

extraLongFactorials(n);

scanner.close();
}
}

0 comments on commit 9201866

Please sign in to comment.