Let us define the operation of rebasing a number as writing out its digits in decimal form, then interpreting them in the smallest base N
possible (2 <= n <= 10
). For example, rebasing the number 1234
gives 194
, since the smallest base that "1234"
can be interpreted in is base 5
, and "1234"
interpreted in base 5
is 194
in decimal.
Challenge
Given a positive integer n
, output n
rebased as a decimal integer.
Expected output
Below is a list of the results of rebasing each number from 1 to 200:
1,2,3,4,5,6,7,8,9,2,3,5,7,9,11,13,15,17,19,6,7,8,11,14,17,20,23,26,29,12,13,14,15,19,23,27,31,35,39,20,21,22,23,24,29,34,39,44,49,30,31,32,33,34,35,41,47,53,59,42,43,44,45,46,47,48,55,62,69,56,57,58,59,60,61,62,63,71,79,72,73,74,75,76,77,78,79,80,89,90,91,92,93,94,95,96,97,98,99,4,5,11,19,29,41,55,71,89,109,6,7,14,23,34,47,62,79,98,119,15,16,17,27,39,53,69,87,107,129,28,29,30,31,44,59,76,95,116,139,45,46,47,48,49,65,83,103,125,149,66,67,68,69,70,71,90,111,134,159,91,92,93,94,95,96,97,119,143,169,120,121,122,123,124,125,126,127,152,179,153,154,155,156,157,158,159,160,161,189,190,191,192,193,194,195,196,197,198,199,18
And some more cases:
in => out
1011010 90
10201 100
32021 905
11014 759
12345 1865
4326 1539
70707 29127
8314 6088
56789 56789
This is code-golf.
Note that this is OEIS entry A068505.