The base ten integer 839 has the representations 1132 and 11324 respectively in base 9 and base 5. Accordingly, 839 has a base 5 representation that begins with its base 9 representation.
For which other base ten integers between 10 and 2014 inclusively do the base 5 representation of the integer begin with its base 9 representation?
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
For n = 10 To 200000
b5$ = base$(n, 5)
b9$ = base$(n, 9)
If InStr(b5$, b9$) = 1 Then
Text1.Text = Text1.Text & Str(n) & " " & b5$ & " " & b9$ + crlf
DoEvents
End If
Next
End Sub
Function base$(n, b)
v$ = ""
n2 = n
Do
d = n2 Mod b
n2 = n2 \ b
v$ = LTrim(Str(d)) + v$
Loop Until n2 = 0
base$ = v$
End Function
attempts n through 200,000, but finds all the valid numbers under 2000:
base
10 5 9
------------------
839 11324 1132
840 11330 1133
894 12034 1203
895 12040 1204
900 12100 1210
1739 23424 2342
1740 23430 2343
1794 24134 2413
1795 24140 2414
1800 24200 2420
|
Posted by Charlie
on 2014-05-26 16:47:35 |