8833 = 88^2 + 33^2
As you see, the above number is equal to the sum of the squares of its two halves.
Provide all numbers below 1,000,000
possessing this feature.
Bonus question: As above, but the numbers should be equal to the sum of the cubes of their thirds, i.e. ABCDEF= (AB)^3+(CD)^3+(EF)^3
Squared halves
1233
8833
990100
Cubed thirds
153
370
371
407
165033
221859
336700
336701
340067
341067
407000
407001
444664
487215
982827
983221
166500333
296584415
333667000
333667001
334000667
710656413
828538472
BTW, a little tweak to the below program also finds for the squared halves portion 94122353 = 9412^2 + 2353^2.
from
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
ulimplus1 = 10
For digs = 1 To 3
lowlim = ulimplus1 / 10
upplim = ulimplus1 - 1
For a = lowlim To upplim
For b = 0 To upplim
DoEvents
a2 = a * a
b2 = b * b
n = a * ulimplus1 + b
If n = Val(a2 + b2) Then
Text1.Text = Text1.Text & n & crlf
End If
Next
Next
ulimplus1 = ulimplus1 * 10
Next
ulimplus1 = 10
For digs = 1 To 3
lowlim = ulimplus1 / 10
upplim = ulimplus1 - 1
For a = lowlim To upplim
For b = 0 To upplim
For c = 0 To upplim
DoEvents
a3 = a * a * a
b3 = b * b * b
c3 = c * c * c
n = a * ulimplus1 * ulimplus1 + b * ulimplus1 + c
If n = Val(a3 + b3 + c3) Then
Text1.Text = Text1.Text & n & crlf
End If
Next
Next
Next
ulimplus1 = ulimplus1 * 10
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
|
Posted by Charlie
on 2016-06-10 15:02:02 |