Find all possible integers P, Q, R and S with 1 ≤ P ≤ Q ≤ R ≤ S satisfying this equation:
PQ+RS = P+Q+R+S+3
p q r s lhs & rhs
1 1 2 6 13
2 2 3 3 13
1 2 2 6 14
2 2 2 5 14
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For tot = 3 To 1000
For p = 1 To tot / 4
For q = p To (tot - p) / 3
For r = q To (tot - p - q) / 2
s = tot - p - q - r
If p * q + r * s = p + q + r + s + 3 Then
Text1.Text = Text1.Text & p & Str(q) & Str(r) & Str(s) & " " & p * q + r * s & crlf
DoEvents
End If
Next
Next
Next
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
|
Posted by Charlie
on 2015-06-20 14:44:33 |