On 02/01/2011 05:12 PM, David Winsemius wrote:
On Feb 1, 2011, at 3:51 PM, Kiogou Lydie wrote:
Yet, j! will stop at 170 and Π (i-1-d) at 172; so, a[j] will
not exceed 170.
I would like to have at least 200 a[j].
> factorial(200)
[1] Inf
Warning message:
In factorial(200) : value out of range in 'gammafn'
This is quite a nice number with 375 digits. You can compute it
'within' R with a call to, e.g., the arbitrary precision calculator bc,
using the r-bc package [1] by Gabor Grothendieck:
library(bc)
factorial = function(n) bc(sprintf('
define factorial(n) {
if (n < 2) return (1)
f = 2
i = 2
while (i < n) f *= ++i
return (f) }
factorial(%d)', n))
f200 = factorial(200)
f2000 = factorial(2000)
f20000 = factorial(20000)
...
The outcome is an object of the class 'bc', and you can (carefully)
perform computations with it (with bc doing the job behind the scenes,
as R cannot store integers of this magnitude).
vQ
[1] http://code.google.com/p/r-bc/
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.