Determine the smallest positive integer that is expressible as the product of three distinct positive integers in arithmetic sequence in precisely two ways.
What are the next two smallest positive integers with this property?
**** As an example, 105 is expressible as the product of three positive integers (3, 5 and 7) in arithmetic sequence in only one way as no other positive integer triplet in arithmetic sequence multiplies to 105.
The first 7 (under 2000) are:
n ways
231 2
440 2
504 2
840 2
1560 2
1680 2
1848 2
The first three's details are:
n sequence
231 1 11 21
231 3 7 11
440 2 11 20
440 5 8 11
504 4 9 14
504 7 8 9
By rearranging the output of:
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
high = 2000
ReDim ways(high)
For a = 1 To high
For d = 1 To high - a
s = a * (a + d) * (a + 2 * d)
If s <= high Then ways(s) = ways(s) + 1 Else Exit For
If s = 231 Or s = 440 Or s = 504 Then
Text1.Text = Text1.Text & s & Str(a) & Str(a + d) & Str(a + 2 * d) & crlf
End If
Next
Next
For i = 1 To high
If ways(i) = 2 Then Text1.Text = Text1.Text & i & Str(ways(i)) & crlf: DoEvents
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
The lines
If s = 231 Or s = 440 Or s = 504 Then
Text1.Text = Text1.Text & s & Str(a) & Str(a + d) & Str(a + 2 * d) & crlf
End If
were obviously added after the first run determined the first three solutions.
|
Posted by Charlie
on 2015-08-13 14:52:35 |