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)
Initially I glossed over the apparent requirement that the starting integer was in base-10, and produced the first program below. I then produced the second program, at bottom, to get missed answers, as apparently the portion for part (d) did not go to high enough base.
To summarize:
(a) decimal 316 is 631 in base 7
(b) --- not yet found ---
(c) --- not yet found but decimal 227 is 272 in base 9 ---
(d) decimal 8200 is 2008 in base 16
General base to base program
clearvars,clc
for i=106:10:10000
n=char(string(i));
nr=[n(end) n(1:end-1)];
for b2=8:11
for b1=b2-1:-1:7
try
if base2base(nr,b1,b2)==char(string(i))
disp([str2num(nr) b1 b2 i base2dec(nr,b1) base2dec(n,b2)])
end
catch
end
end
end
end
disp('---------------------')
for i=103:10:10000
n=char(string(i));
nr=[n(end) n(1:end-1)];
for b1=8:11
for b2=b1-1:-1:4
try
if base2base(nr,b1,b2)==char(string(i))
disp([str2num(nr) b1 b2 i base2dec(nr,b1) base2dec(n,b2)])
end
catch
end
end
end
end
disp('---------------------')
for i=102:10:10000
n=char(string(i));
nr=[n(end) n(1:end-1)];
for b1=8:11
for b2=b1-1:-1:3
try
if base2base(nr,b1,b2)==char(string(i))
disp([str2num(nr) b1 b2 i base2dec(nr,b1) base2dec(n,b2)])
end
catch
end
end
end
end
disp('---------------------')
for i=108:10:10000
n=char(string(i));
nr=[n(end) n(1:end-1)];
for b2=8:13
for b1=b2-1:-1:9
try
if base2base(nr,b1,b2)==char(string(i))
disp([str2num(nr) b1 b2 i base2dec(nr,b1) base2dec(n,b2)])
end
catch
end
end
end
end
disp('---------------------')
finding
626 7 11 266 314 314
631 7 10 316 316 316
---------------------
360 9 7 603 297 297
366 11 8 663 435 435
---------------------
227 10 9 272 227 227
240 9 7 402 198 198
244 11 8 442 290 290
255 9 6 552 212 212
262 11 7 622 310 310
2315 10 9 3152 2315 2315
2657 11 8 6572 3450 3450
---------------------
840 9 13 408 684 684
858 9 11 588 701 701
861 11 13 618 1035 1035
8474 9 11 4748 6223 6223
---------------------
>>
explanation of above by example of the first row:
626 in base 7, when expressed in base 11 is 266. Each is equal to 314 decimal.
Second program, assuming starting in decimal for parts (b) thru (d)
for i=[300:399 3000:3999 30000:39999]
n=char(string(i));
nr=[n(2:end) n(1)];
for b=4:9
try
if base2dec(nr,b)==i
disp([n ' ' nr ' ' char(string(b))])
end
catch
end
end
end
disp('---------------')
for i=[800:899 8000:8999 80000:89999]
n=char(string(i));
nr=[n(2:end) n(1)];
for b=11:18
try
if base2dec(nr,b)==i
disp([n ' ' nr ' ' char(string(b))])
end
end
end
end
finding
>> moveDigitChangeBase10
---------------
8200 2008 16
b and c still not found.
|
Posted by Charlie
on 2022-04-19 11:16:24 |