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

 Get the bases! (Posted on 2018-10-17)
The number 1987 can be written as a three digit number xyz in some base b.
If x + y + z = 1 + 9 + 8 + 7=25, determine all possible values of x, y, z, b.

 See The Solution Submitted by Ady TZIDON No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 re: computer soln --- my program for it | Comment 2 of 5 |
(In reply to computer soln by Steven Lord)

DefDbl A-Z
Dim crlf\$, dig(10)

Form1.Visible = True

Text1.Text = ""
crlf = Chr\$(13) + Chr\$(10)

n = 1987: tot = 25

For bs = 10 To 5000
If base(n, bs) = 3 Then
t = 0
For i = 0 To base(n, bs) - 1
t = t + dig(i)
Next
If t = tot Then
For i = 2 To 0 Step -1
Text1.Text = Text1.Text & Str(dig(i))
Next
Text1.Text = Text1.Text & Str(bs) & crlf
End If
ElseIf Len(s) < 3 Then
Exit For
End If
Next

Text1.Text = Text1.Text & crlf & " done"

End Sub

Function base(n, b)
n2 = n
p = 0
Do
d = n2 Mod b
n2 = n2 \ b
dig(p) = d
p = p + 1
Loop Until n2 = 0
base = p
End Function

The program stopped (exited the loop) when the number of digits became less than 3 so did not require figuring the limit of the base

So no solution was given beyond:

5 9 11 19

being the three digits and the base, each expressed in decimal.

 Posted by Charlie on 2018-10-17 11:39:24

 Search: Search body:
Forums (0)