There are three infinite arithmetic progressions.
Given that each of the numbers 1,2,3,4,5,6,7,8 occurs at least in one of these progressions, show that the number 1248 must occur at least in one of them.
Checking every partition into three groups, (6561 partitions counted as checked, which is 3^8):
DefDbl A-Z
Dim crlf$, prg$(3)
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For one = 1 To 3
prg(one) = prg(one) + "1"
For two = 1 To 3
prg(two) = prg(two) + "2"
For three = 1 To 3
prg(three) = prg(three) + "3"
For four = 1 To 3
prg(four) = prg(four) + "4"
For five = 1 To 3
prg(five) = prg(five) + "5"
For six = 1 To 3
prg(six) = prg(six) + "6"
For seven = 1 To 3
prg(seven) = prg(seven) + "7"
For eight = 1 To 3
prg(eight) = prg(eight) + "8"
partitions = partitions + 1
found = 0
For p = 1 To 3
If Len(prg(p)) > 1 Then
If Len(prg(p)) = 2 Then
If p = 2 Then
x = x
End If
diff = Val(Right(prg(p), 1)) - Val(Left(prg(p), 1))
If diff <= 0 Then
Text1.Text = Text1.Text & "PROGRAM ERROR"
Exit Sub
End If
diffmajor = 1248 - Val(Left(prg(p), 1))
If diffmajor Mod diff = 0 Then
found = 1
Exit For
End If
Else
diff = Val(Mid(prg(p), 2, 1)) - Val(Left(prg(p), 1))
For i = 3 To Len(prg(p))
diff2 = Val(Mid(prg(p), i, 1)) - Val(Mid(prg(p), i - 1, 1))
If diff <= 0 Or diff2 <= 0 Then
Text1.Text = Text1.Text & "PROGRAM ERROR"
Exit Sub
End If
diff = gcd(diff, diff2)
Next
diffmajor = 1248 - Val(Left(prg(p), 1))
End If
If diffmajor Mod diff = 0 Then
found = 1
Exit For
End If
End If
Next
If found = 0 Then
For j = 1 To 3
Text1.Text = Text1.Text & prg(j) & " "
Next
Text1.Text = Text1.Text & crlf
End If
ix = InStr(prg(eight), "8")
prg(eight) = Left(prg(eight), ix - 1) + Mid(prg(eight), ix + 1)
Next
ix = InStr(prg(seven), "7")
prg(seven) = Left(prg(seven), ix - 1) + Mid(prg(seven), ix + 1)
Next
ix = InStr(prg(six), "6")
prg(six) = Left(prg(six), ix - 1) + Mid(prg(six), ix + 1)
Next
ix = InStr(prg(five), "5")
prg(five) = Left(prg(five), ix - 1) + Mid(prg(five), ix + 1)
Next
ix = InStr(prg(four), "4")
prg(four) = Left(prg(four), ix - 1) + Mid(prg(four), ix + 1)
Next
ix = InStr(prg(three), "3")
prg(three) = Left(prg(three), ix - 1) + Mid(prg(three), ix + 1)
Next
ix = InStr(prg(two), "2")
prg(two) = Left(prg(two), ix - 1) + Mid(prg(two), ix + 1)
Next
ix = InStr(prg(one), "1")
prg(one) = Left(prg(one), ix - 1) + Mid(prg(one), ix + 1)
Next
Text1.Text = Text1.Text & crlf & partitions & " done"
End Sub
Function gcd(a, b)
x = a: y = b
Do
q = Int(x / y)
z = x - q * y
x = y: y = z
Loop Until z = 0
gcd = x
End Function
No sets were found where no partition formed a progression without 1248.
|
Posted by Charlie
on 2016-09-06 10:19:42 |