What are the largest values of n for which n! has fewer then 100 decimal digits, fewer than 1000 decimal digits, and fewer than 10,000 decimal digits?라는 질문을 보고 간단히 perl script로 결과를 구해봤다.
69!, 449!, 3248!이 각각 10진수로 99자리, 998자리, 9998자리이다.
다음은 코드와 결과이다.
use strict;
use bigint;
my $d = 10000;
my ($i, $n) = (1, 1);
while(1)
{
$n *= $i;
last if length($n * $i) >= $d;
$i++;
}
print "$i factorial: $n [", length($n), " digits]\n";
69 factorial: 171122452428141311372468338881
27283909227054489352036939364804092325
7279754140647424000000000000000 [99 digits]
449 factorial: 385193051802807257632158476912
12875548395805893534467012649055767896288
926298594457881668628676415791435136187818
72021746359685290289255601854954706967037
237815981933427173547163838273480784018675
12495830429837203000813557811307516010999
35399420025859541702588941624119769786447
979635875887987628187121141743814227340405
786877075540700136227919818634007425579126
136583156012933348747449102149815962647863
834705576714179015069575989844000509497340
761230129254648880664249707996772824842574
358558533486456993617018144080838058452833
163022395716238804463454122374136551392458
4025461354677759729187297731663124277878618
877498334677521800812698843489928636349843
038102559471536632660957843998883126988557
88258154809005327539117440908208905353330
891394428678158921052069748074205537868136
717094006764031023426591318276097353833638
375226039787340475684974328746914841262748
8289694186769477953126400000000000000000
0000000000000000000000000000000000000
0000000000000000000000000000000000000
0000000000000 [998 digits]
3248 factorial은 너무 길어서 생략.