Given: The sum of the squares of a and its reverse b (i.e. the number read from right to left) is a perfect square.
Find the sides a,b,c of this peculiar right-angled triangle.
Source: This property was discovered by Victor Thébault in 1959.
Searching up through 7-digit numbers, the program finds three solutions:
Numbers Squares
88209 90288 126225 7780827681 8151922944 15932750625
90288 88209 126225 8151922944 7780827681 15932750625
125928 829521 839025 15857861184 688105089441 703962950625
829521 125928 839025 688105089441 15857861184 703962950625
5513508 8053155 9759717 30398770466064 64853305454025 95252075920089
8053155 5513508 9759717 64853305454025 30398770466064 95252075920089
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For a = 1 To 9999999
DoEvents
ast$ = LTrim(Str(a))
b = 0
For i = Len(ast) To 1 Step -1
b = b * 10 + Val(Mid(ast, i, 1))
Next
csq = a * a + b * b
sr = Int(Sqr(csq) + 0.5)
If sr * sr = csq And Len(ast) = Len(LTrim(Str(b))) Then
'(the length check prevents trailing zero from becoming a non-showing leading zero)
c = sr
Text1.Text = Text1.Text & a & Str(b) & Str(c) & " " & Str(a * a) & Str(b * b) & Str(c * c) & crlf
End If
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Edited on April 8, 2016, 7:23 pm
|
Posted by Charlie
on 2016-04-08 19:21:59 |