Created
February 13, 2017 07:27
-
-
Save M-ZubairAhmed/cdd87cd0c20ec6ce137a029f801d6b43 to your computer and use it in GitHub Desktop.
Calculating factorial of huge numbers using BigInteger Java class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//bNum = Initializing big interger to value. | |
BigInteger bNum = BigInteger.ONE; | |
// n = The input number whose factorial is to be calculated. | |
for (long i = 1; i <= n; i++) { | |
bNum = bNum.multiply(bNum.valueOf(i)); | |
} | |
//Storing the value of factorial in a string. | |
String factorialValue = String.valueOf(bNum); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment