(In reply to
Godel strikes again by Steve Herman)
? 31
mult prod w/o zeros
97 3007 37
11 407 47
64 3008 38
55 2090 29
69 2001 21
48 1008 18
5 90 9
? 33
31 1023 123
82 10086 186
54 10044 144
75 10800 18
5 90 9
from
10 N0=1
20 while N0>0
30 input N0
40 if N0=0 then end
50 N=N0:Pn=0
60 while N>9 and N<>Pn
65 Pn=N
70 Max0=-1:Besti=1:Bestprod=N
80 for I=1 to 99
90 Prod=N*I
100 Z=fnCtzero(Prod)
110 if Z>Max0 and I @ 10<>0 and fnNozero(Prod)<>N then Max0=Z:Besti=I:Bestprod=Prod
120 next I
130 N=fnNozero(Bestprod)
140 print Besti,Bestprod,N
150 wend
160 wend
170
180 fnCtzero(Num)
190 local Ct,I,Ns
200 Ns=str(Num)
210 Ct=0
220 for I=1 to len(Ns)
230 if mid(Ns,I,1)="0" then inc Ct
240 next
250 return(Ct)
260
270 fnNozero(Num)
280 local Ns,N,I
290 Ns=cutspc(str(Num))
300 N=0
310 for I=1 to len(Ns)
320 if mid(Ns,I,1)>"0" then N=10*N+val(mid(Ns,I,1))
330 next
340 return(N)
|
Posted by Charlie
on 2013-07-26 09:53:15 |