Today the integer ages of brothers Alex, Bert, and Carl form an arithmetic progression.
Two months later, after Alex's birthday, the ages form a geometric progression.
Is Alex the oldest, youngest, or middle child?
oldest 1 2 3
youngest 3 6 9
oldest 4 6 8
youngest 8 12 16
oldest 9 12 15
youngest 15 20 25
oldest 16 20 24
youngest 24 30 36
oldest 25 30 35
youngest 35 42 49
oldest 36 42 48
youngest 48 56 64
oldest 49 56 63
youngest 63 72 81
oldest 64 72 80
youngest 80 90 100
oldest 81 90 99
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For x = 1 To 100
For y = x + 1 To 100
DoEvents
d = y - x
z = y + d
xp = x + 1: yp = y + 1: zp = z + 1
sq = xp * z
If y * y = sq Then Text1.Text = Text1.Text & "youngest " & x & Str(y) & Str(z) & crlf
sq = x * z
If yp * yp = sq Then Text1.Text = Text1.Text & "middle " & x & Str(y) & Str(z) & crlf
sq = x * zp
If y * y = sq Then Text1.Text = Text1.Text & "oldest " & x & Str(y) & Str(z) & crlf
Next y
Next x
Text1.Text = Text1.Text & crlf & " done"
End Sub
|
Posted by Charlie
on 2017-01-16 16:01:35 |