Find the smallest positive base 10 integer, for each of (a) through (d), (but with a 3-digit minimum), such that moving a digit is equivalent to changing the base from 10 to some other base which you must determine, according to one specific condition below:
(a) Moving a 6 from last digit to first changes from base 10 to a smaller base
(b) Moving a 3 from first digit to last changes from base 10 to a smaller base
(c) Moving a 2 from last digit to first changes from base 10 to a larger base
(d) Moving an 8 from first digit to last changes from base 10 to a larger base
Note: The new base may be different for each of (a) to (d)
(a)
for i=[106:10:9996 ]
n= char(string(i));
nr=[n( end) n(1:end-1)];
for b=9:-1:7
try
if base2dec(nr,b)==i
disp([n ' ' nr ' ' char(string(b))])
end
end
end
end
finds
dec b-n n
316 631 7
(b)
for i=[300:399 3000:3999 30000:39999 300000:399999]
n= (char(string(i)));
nr=[ n(2:end), n(1)];
for b=9:-1:4
try
if base2dec(nr,b)==i
disp([n ' ' nr ' ' char(string(b))])
end
end
end
end
>> moveDigitChangeBase10
361020 610203 9
>>
(c)
for i=[102:10:9992 2000:2999]
n= char(string(i));
nr=[n( end) n(1:end-1)];
for b=11:36
if base2dec(nr,b)==i
disp([n ' ' nr ' ' char(string(b))])
end
end
end
finds
782 278 18
882 288 19
5272 2527 13
(d)
for i=[800:899 8000:8999 80000:89999 800000:899999]
n= (char(string(i)));
nr=[ n(2:end), n(1)];
for b=11:20
if base2dec(nr,b)==i
disp([n ' ' nr ' ' char(string(b))])
end
end
end
finds
825 258 19
8200 2008 16
853311 533118 11
|
Posted by Charlie
on 2022-04-21 09:17:31 |