 All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars  perplexus dot info  Four integers (Posted on 2016-12-04) Find four distinct positive integers such that:
a. Each of them is below 500.
b. Multiplying any two of them and then incrementing the product by 1
produces a square number.

 No Solution Yet Submitted by Ady TZIDON No Rating Comments: ( Back to comment list | You must be logged in to post comments.) computer solution (spoiler) | Comment 1 of 8
DefDbl A-Z
Dim crlf\$, n(4)

Form1.Visible = True

Text1.Text = ""
crlf = Chr\$(13) + Chr\$(10)

For a = 1 To 496
n(1) = a
Next

Text1.Text = Text1.Text & crlf & " done"

End Sub

For newNum = n(wh - 1) + 1 To 499
n(wh) = newNum
good = 1
For i = 1 To wh - 1
For j = i + 1 To wh
DoEvents
sq = n(i) * n(j) + 1
sr = Int(Sqr(sq) + 0.5)
If sr * sr <> sq Then good = 0: Exit For
Next
If good = 0 Then Exit For
Next
If good Then
If wh = 4 Then
For i = 1 To 4
Text1.Text = Text1.Text & Str(n(i))
Next
Text1.Text = Text1.Text & crlf
Else
End If
End If
Next
End Sub

finds these two solutions:

1 3 8 120
2 4 12 420

 Posted by Charlie on 2016-12-04 11:01:08 Please log in:

 Search: Search body:
Forums (4)