Hi all,
I've been trying to come up with a way to calculate factorials of very large numbers (example: of 2032597) and currently I'm stuck on the implementation of the Stirling's approximation. I tried using bignum but I keep getting an error stating: "Can't use an undefined value as an ARRAY reference at C:/Perl/../Calc.pm"
In this approximation, $exp evaluates to ~2.8e11938980. Is this number too large to be used in perl?
use Math::Trig; use bignum; sub factorial { my $n = @_; my $root = sqrt($n*2*pi); my $exp = ($n/exp(1))^$n; my $result =$root*$exp; return $result; } my $b = 2032597; my $r = Math::BigInt->new(factorial($b)); print "b is $b\n"; print "the calculated result is $r\n";
In reply to Operations with Extremely Large Numbers by jjw017
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |