# TITLE: Factorials of Big Integers # AUTHOR: BazzaB # EMAIL: barries_ecdl@hotmail.com # DATE: 1st December 2003 # MAKE: Casio # MODEL: version 1:9850G , version2: earlier models # NOTES: Gives factorials much larger than the mere 69 factorial which is # generally the most that an ordinary calculator can handle. # # This program uses the Improved Stirling's Method, and whilst not showing all # of the many thousands of digits in the larger results, the answers are # guaranteed to be accurate to within about 0.0003 per cent. # Of course, 0.0003 per cent of 8 times 10 to the power 5 million is still an # absolute error of hundreds of thousands of millions, but the relative error # is still very small. # # As a bonus, it also shows the number of trailing zeroes. # KEYS: # * multiply by below [ DEL ] # / divide by below [ AC/ON ] # -> assignment above [ AC/ON ] # <> not equal shift vars f6 f3 f2 # \10^ ten to the power small 10. shift [ log ] # \sum summation optn f4 f6 f3 # nCr combinations optn f6 f3 f3 ( fat letter C ) # \pi 3.14159265358 shift [ EXP ] # _ underscore shift vars f5 ( 'display' triangle ) #__________________________________________________ @@ Program "BIGFRIAL" Lbl 1:0->A~B:Do:ClrText "ENTER INTEGER":"70 TO 1,000,000,000":?->A LpWhile Frac A+(A<70)+(A>\10^9 .5log 2\pi+log A(A+.5)+1/ln 10*(1/(12A+.002)-A)->B ClrText:"FACTORIAL":Locate 11,1,A "IS":Locate 5,2,\10^Frac B "X10 TO THE POWER":Int B_ ClrText:"TRAILING ZEROES =" Locate 5,2,\sum(Int (A/5^B),B,1,9 Locate 6,6,"PRESS 'EXE'":Locate 6,7,"FOR ANOTHER" Do:Getkey->A:LpWhile A<>31:Goto 1 #__________________________________________________ @@ Program "BF" ?->A .5log 2\pi+log A(A+.5)+1/ln 10*(1/(12A+.002)-A)->B \10^Frac B_ "X10^":Int B_ "ZEROES" 0->S:9->C:Lbl 1 S+Int (A/5^C)->S Dsz C:Goto 1