Given a strictly increasing sequence of seven positive integers such that:
a. Each number (excluding the first) is a multiple of the one before it.
b. The sum of all seven numbers is 559.
c. Neither 0 nor 8 are used in any of the 7 numbers.
What is the last number in the sequence?
DefDbl A-Z
Dim h(6), crlf$, tot
Function mform$(x, t$)
a$ = Format$(x, t$)
If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
mform$ = a$
End Function
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
For s = 1 To 559 / 7
m = 2
Do
rhs = (559 / s) * (m - 1) + 1
pm = m
m = rhs ^ (1 / 7)
Loop Until m = pm
Text1.Text = Text1.Text & mform(s, "##0") & " " & mform(m, "##0.0000000") & mform(s * m ^ 6, "####0.0000000")
tot = 0
For i = 0 To 6
tot = tot + s * m ^ i
Next
Text1.Text = Text1.Text & mform(tot, "####0.0000000") & crlf
Next
Text1.Text = Text1.Text & crlf & crlf
For s = 1 To 50
h(0) = s: tot = s
addOn 1
Next
End Sub
Sub addOn(wh)
For m = 2 To 20
h(wh) = h(wh - 1) * m
tot = tot + h(wh)
If tot <= 559 Then
If tot < 559 Then
If wh < 6 Then
addOn wh + 1
End If
Else
If wh = 6 Then
For i = 0 To 6
Text1.Text = Text1.Text & mform(h(i), "####0")
Next
Text1.Text = Text1.Text & crlf
End If
End If
End If
tot = tot - h(wh)
Next m
End Sub
The first part of the program merely verifies there's no integral solution if the assumption is made that the same multiple is used each generation in the series.
The second part of the program gives the following series, based on rules a and b:
1 2 4 8 16 48 480
1 2 4 8 16 176 352
1 2 4 8 32 64 448
1 2 4 8 32 128 384
1 2 4 12 36 72 432 **
1 2 4 12 60 120 360
1 2 4 24 48 96 384
1 6 12 36 72 144 288
Only the sequence I've marked with double asterisk fits rule c.
|
Posted by Charlie
on 2015-03-05 10:48:21 |