Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the exact value of factorial(100)

Tags:

r

When I run factorial(100) in the console, I get

factorial(100)
# [1] 9.332622e+157

But I want to see the exact value of factorial(100). How would I do it?

like image 268
Noah Xu Avatar asked Dec 08 '15 23:12

Noah Xu


1 Answers

The gmp library might do what you want. I have not verified that this is the correct result:

> library(gmp)
> j <- as.bigz(100)
> factorial(j)
Big Integer ('bigz') :
[1] 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000

See also Multiplication of large integers in R

like image 194
Matthew Lundberg Avatar answered Oct 20 '22 00:10

Matthew Lundberg