5 F=1:P=10^250
10 for I=1 to 10000
20 F=(F*I)@P
25 while F @ 10=0
26 F=F\10:inc ZeroCt
27 wend
30 next
40 print F,ZeroCt
produces
4323189708690304003013259514767742375161588409158380591516735045191311781939434
28482922272304061422582078027829148070426761629302539228321084917759984200595105
31216473181840949313980044407284732590260916973099815385393903128087882390294800
1579008 2499
indicating that before the terminal 2499 zeroes, the previous digit is an 8.
I think the problem with taking the last non-zero digit of 10000! as being that of (10!)^(1000) is that in subsequent decades different numbers of multiples of 2 and of 5 go into the zeros rather than contributing to the last non-zero digit.
As an example, take this table of factorials:
10 3628800
20 2432902008176640000
30 265252859812191058636308480000000
40 815915283247897734345611269596115894272000000000
50 30414093201713378043612608166064768844377641568960512000000000000
The last non-zero digit of 30! is not the 2 that you would expect, as the last non-zero digit of (10!)^3.
|
Posted by Charlie
on 2011-10-02 14:09:04 |