Find all 2 digit base 10 integer pairs (X, Y) such that:
- Y is not larger than X
- (sod(X*Y))^3 equals (sod(X))^2 + (sod(Y))^2
... where sod(n) indicates the sum of digits of n
x y x*y (sod(x*y))^3
(sod(x))^2+(sod(y))^2
73 14 1022 125
50 28 1400 125
50 46 2300 125
64 50 3200 125
82 50 4100 125
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For y = 10 To 99
For x = y To 99
tst1 = sod(x * y)
tst1 = tst1 * tst1 * tst1
sx = sod(x): sy = sod(y)
tst2 = sx * sx + sy * sy
If tst1 = tst2 Then
Text1.Text = Text1.Text & x & Str(y) & Str(x * y) & Str(tst1) & crlf
End If
DoEvents
Next x
Next y
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
Edited on November 20, 2019, 2:16 pm
|
Posted by Charlie
on 2019-11-20 14:15:56 |