clearvars
v=sym(11); ct=0; prev=0; mx=0;
for i=2:50000
v=v*11;
tst=char(v-1);
ct=0;
j=length(tst);
while tst(j)=='0'
ct=ct+1;
j=j-1;
end
if ct>=mx
disp([i,ct])
mx=ct;
end
prev=ct;
end
>> howManyZerosAtEnd
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 2
20 2
30 2
40 2
50 3
100 3
150 3
200 3
250 3
300 3
350 3
400 3
450 3
500 4
1000 4
1500 4
2000 4
2500 4
3000 4
3500 4
4000 4
4500 4
5000 5
10000 5
15000 5
20000 5
25000 5
30000 5
35000 5
40000 5
45000 5
50000 6
All results have at least one trailing zero.
Multiples of 10 have at least two.
Multiples of 50 have at least three.
Multiples of 500 have at least four.
Multiples of 5000 have at least five.
Multiples of 50,000 have at least six.
etc.
Manual testing:
>> powermod(sym(11),100000,100000000)
ans =
46000001
>> powermod(sym(11),500000,100000000)
ans =
30000001
>>
|
Posted by Charlie
on 2024-04-05 12:51:10 |