By definition, bigint works by overloading literal processing with integers and floating point, converting them to Math :: BigInt objects. Thus, using a simple for loop, we can get a factorial of very large integers.
use bigint; my $fact = 1; for my $n (1..100) { $fact *= $n; } print "Factorial: \n", $fact , "\n";
This gives the following result:
Factorial: 933262154439441526816992388562667004907159682643816214685929638952175 99993229915608941463976156518286253697920827223758251185210916864000000000000000 000000000
whereas a regular program like this would tremble without a meaningful exit
use integer; my $fact = 1; for my $n (1..100) { $fact *= $n; } print "Factorial: \n", $fact , "\n";
Output:
Factorial: 0
Swadhikar c
source share