Dudeney once asked what positive numbers have cube roots equal to the sum of
their digits.
Excluding the trivial (i.e. number 1) Dudeney listed five solutions!
Find them!
Hint: the five numbers are below 25000.
sod number
1 1
8 512
17 4913
18 5832
26 17576
27 19683
from
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For cr = 1 To 100000
cu = cr * cr * cr
If cr = sod(cu) Then
Text1.Text = Text1.Text & cr & " " & cu & crlf
End If
DoEvents
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Function sod(n)
s$ = LTrim(Str(n))
tot = 0
For i = 1 To Len(s$)
tot = tot + Val(Mid(s$, i, 1))
Next
sod = tot
End Function
|
Posted by Charlie
on 2018-03-09 12:21:01 |