With 3 digits (3*37^0), it's divisible by 37^1
With 111 digits (3*37^1), it's divisible by 37^2
With 4107 digits (3*37^2), it's divisible by 37^3
With 151959 digits (3*37^3), it's divisible by 37^4
With 5622483 digits (3*37^4), it's divisible by 37^5
higher than that, the numbers exceed the range of variable precision arithmetic (vpa) in MATLAB (at least beyond which I wish to stretch it).
But, extrapolating, the greatest value of n in question would be 2001.
Program originally had smaller number of digits and an actual range of values of powers; higher precision slows things down and I did one at a time (range 4:4 for example).
digits 7000000
n=''; d=0;
for reppwr=4:4
reps=37^reppwr;
n=repmat('111',1,reps);
d=length(n);
num=vpa(n);
ct=0;
while mod(num,37)==0
ct=ct+1;
num=num/37;
end
% if ct>1
disp([d d/111 ct mod(num,37)])
% end
end
Edited on June 17, 2021, 10:32 am
|
Posted by Charlie
on 2021-06-17 10:11:19 |