5

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?

Rich Scriven
  • 97,041
  • 11
  • 181
  • 245
Noah Xu
  • 167
  • 3
  • 11

1 Answers1

6

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

Community
  • 1
  • 1
Matthew Lundberg
  • 42,009
  • 6
  • 90
  • 112