Divide the set of integers from 1 to 15 into 2 subsets - a subset A of 13 numbers and B of 2 numbers so that the sum of the members of A equals the product of the two numbers in B.
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For a = 1 To 15
For b = a + 1 To 16
prod = a * b
tot = 136 - a - b
If prod = tot Then
Text1.Text = Text1.Text & a & Str(b) & crlf
End If
Next
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Of course a and b here are the two numbers that are to be multiplied and 136 is the total of all the numbers from 1 to 16.
|
Posted by Charlie
on 2016-03-01 09:17:38 |