I know that BigInteger
is the class to use when handling really large numbers. I wrote a simple script that calculates factorial. However, it breaks at input 25 and above.
/**
* Calculates the factorial of a given number
*/
BigInteger fact(long n){
def fact = 1
while(n > 0){
fact *= n--
}
return fact
}
What is the right way to handle numbers as large as 100! ?