Any three of the integers {1, X, Y, Z} add up to a perfect square.
What are X, Y, & Z?
Hint: each is below 100.
(In reply to
re(2): The only way to do it. Confused by Charlie)
Revised the program. These are the answers:
1 1 14 34
1 12 12 12
1 22 41 58
1 24 24 96
n(1) = 1
For x = 1 To 100
n(2) = x
For y = x To 100
n(3) = y
For z = y To 100
n(4) = z
good = 1
For a = 1 To 2
For b = a + 1 To 3
For c = b + 1 To 4
sq = n(a) + n(b) + n(c)
sr = Int(Sqr(sq) + 0.5)
If sr * sr <> sq Then
good = 0: Exit For
End If
Next
Next
If good = 0 Then Exit For
Next
If good Then
For i = 1 To 4
Text1.Text = Text1.Text & Str(n(i))
Next
Text1.Text = Text1.Text & crlf
End If
DoEvents
Next
Next
Next
|
Posted by Charlie
on 2018-01-10 15:56:45 |