Let N(x) be the number 122....221 where the digit 2 occurs x times.
Twice in the
past we have determined the highest power of 11 that divides N(2001) is 11^3.
What is the smallest x for N(x) to be a multiple of 11^3? What about multiples of 11^4 and 11^5?
121 (a single 2) is enough for division by 11^2
12222222222222222222221 (21 2's) is enough for 11^3
241 2's works for 11^4
We overflow the power of UBASIC trying for 11^5
10 N=121:Tst=N:Pwr=0:Twos=1
15 repeat
16 Tst=N:Pwr=0
20 repeat
25 Done=0
40 if Tst@11=0 then Pwr=Pwr+1:else:Done=1
50 Tst=Tst\11:if Tst=0 then Done=1
60 until Done
70 if Pwr>Maxpwr then Maxpwr=Pwr:print N,Maxpwr,Twos:Ct=Ct+1
80 N=int(N/10)*100+21:Twos=Twos+1
90 until Ct>22
which crashes in line 80 when there are already 2591 2's.
A better approach finds 2661 2's works for 11^5:
10 N=121:Tst=N:Pwr=0:Twos=1
11 Eleven5=11^5
15 repeat
20 ' print N@Eleven5
30 if N@Eleven5=96448 then print Twos:Ct=Ct+1
50 if N@Eleven5=0 then print Twos;"*":Ct=Ct+1
80 N=((N1)*10+21)@Eleven5:Twos=Twos+1
90 until Ct>19
The reference to 96448 was made to verify against a known value from the first run, which did not get as far as 2661 2's.

Posted by Charlie
on 20170524 11:32:24 