(In reply to
Similar solution by e.g.)
An implementation of that algorithm
5 for N=2 to 32
10 print N;" ";5^N;" ";:gosub 100:print val(right(K$,N))//5^N
20 next
30 end
100 K=5^N:L=K:K$=cutspc(str(K))
101 while len(K$)<N:K$="0"+K$:wend
110 for I=1 to N
120 if mid(K$,len(K$)-I+1,1)="0" or mid(K$,len(K$)-I+1,1) ="1" or mid(K$,len(K$)-I+1,1)="8" then
130 :K=K+L:K$=cutspc(str(K))
131 :while len(K$)<N:K$="0"+K$:wend
140 L=L*10
150 next
160 print right(K$,N);" ";
180 return
leads to the table below, which lists n, 5^n, the multiple of 5^n that contains no 0's, 1's or 8's, and what multiple that is of 5^n:
2 25 25 1
3 125 625 5
4 625 5625 9
5 3125 65625 21
6 15625 265625 17
7 78125 7265625 93
8 390625 97265625 249
9 1953125 697265625 357
10 9765625 6259765625 641
11 48828125 53759765625 1101
12 244140625 275634765625 1129
13 1220703125 5455322265625 4469
14 6103515625 76666259765625 12561
15 30517578125 463775634765625 15197
16 152587890625 7557525634765625 49529
17 762939453125 39432525634765625 51685
18 3814697265625 699222564697265625 183297
19 19073486328125 6593265533447265625 345677
20 95367431640625 47336673736572265625 496361
21 476837158203125 254633426666259765625 534005
22 2384185791015625 4364664554595947265625 1830673
23 11920928955078125 56266367435455322265625 4719965
24 59604644775390625 529479563236236572265625 8883193
25 298023223876953125 6569396555423736572265625 22043237
26 1490116119384765625 49764443933963775634765625 33396353
27 7450580596923828125 323633767664432525634765625 43437389
28 37252902984619140625 6553496457636356353759765625 175919081
29 186264514923095703125 64966366626322269439697265625 348785525
30 931322574615478515625 447736994363367557525634765625 480753937
31 4656612873077392578125 9662663773633539676666259765625 2075041245
32 23283064365386962890625 93647676543332636356353759765625 4022137081
|
Posted by Charlie
on 2004-08-30 10:42:26 |