All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Reverse Role II (Posted on 2014-12-29)
Determine the minimum value of a three digit octal (base 8) positive integer N that has its digits reversed when expressed in the duodecimal (base 12) system.

Determine the three digit duodecimal (base 12) positive integer N that has its digits reversed when expressed in the hexadecimal (base 16) system.

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution Comment 2 of 2 |
DefDbl A-Z
Dim crlf\$

Function mform\$(x, t\$)
a\$ = Format\$(x, t\$)
If Len(a\$) < Len(t\$) Then a\$ = Space\$(Len(t\$) - Len(a\$)) & a\$
mform\$ = a\$
End Function

ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
Text1.Text = ""
crlf\$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents

For v = 8 * 8 To 8 * 8 * 8 - 1
b8\$ = base\$(v, 8)
b12\$ = base\$(v, 12)
If Len(b12\$) = 3 Then
good = 1
For i = 1 To 3
If Mid(b8\$, i, 1) <> Mid(b12\$, 4 - i, 1) Then good = 0: Exit For
Next
If good Then
Text1.Text = Text1.Text & v & " " & b8\$ & " " & b12\$ & crlf
DoEvents
End If
End If
Next
Text1.Text = Text1.Text & crlf

For v = 12 * 12 To 12 * 12 * 12 - 1
b12\$ = base\$(v, 12)
b16\$ = base\$(v, 16)
If Len(b16\$) = 3 Then
good = 1
For i = 1 To 3
If Mid(b12\$, i, 1) <> Mid(b16\$, 4 - i, 1) Then good = 0: Exit For
Next
If good Then
Text1.Text = Text1.Text & v & " " & b12\$ & " " & b16\$ & crlf
DoEvents
End If
End If
Next
Text1.Text = Text1.Text & crlf

Text1.Text = Text1.Text & " done"
End Sub

Function base\$(n, b)
v\$ = ""
n2 = n
Do
d = n2 Mod b
n2 = n2 \ b
v\$ = Mid("0123456789abcdefghijklmnopqrstuvwxyz", d + 1, 1) + v\$
Loop Until n2 = 0
base\$ = v\$
End Function

finds

decimal 475 = octal 733 = duodecimal 337

decimal 1337 = duodecimal 935 = hexadecimal 539

Edited on December 29, 2014, 9:57 am
 Posted by Charlie on 2014-12-29 09:56:16

 Search: Search body:
Forums (0)