The product of precisely N (N > 2) integers in arithmetic sequence is 1575.
Find the possible values of N.
N can be 7 or 3, based on
(i) Sequence starting at -7, increments of 2, through 5.
It has 4 negative elements, making the product positive 1575:
-7, -5, -3, -1, 1, 3, 5 (7 elements)
(ii) Sequence starting at -25, increments of 16, through 7.
It has 2 negative elements, making the product positive 1575:
-25, -9, 7 (3 elements)
The computer output:
-7 2 5 7
-7 -5 -3 -1 1 3 5
-25 16 7 3
-25 -9 7
from
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For st0 = 1 To 1575
For st = -st0 To st0 Step st0 + st0
For diff = 1 To 1575
DoEvents
prod = 1
k = st: terms = 0
Do
terms = terms + 1
prod = prod * k
If Abs(prod) > 1575 Then Exit Do
If prod = 1575 And terms > 2 Then
Text1.Text = Text1.Text & st & Str(diff) & Str(k) & " " & terms & crlf
For i = st To k Step diff
Text1.Text = Text1.Text & " " & Str(i)
Next
Text1.Text = Text1.Text & crlf
End If
k = k + diff
Loop Until k = 0
Next diff
Next
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
|
Posted by Charlie
on 2016-06-14 09:55:53 |