Sub Checkem()
Dim i As Integer
Dim StartTime As Single, _
EndTime As Single
Dim vTimes(40)
For i = 1 To 40
StartTime = Timer
FindNumbers
EndTime = Timer
vTimes(i) = EndTime - StartTime
Next i
Cells(2, 4).Resize(40, 1) = WorksheetFunction.Transpose(vTimes)
For i = 1 To 40
StartTime = Timer
FindNumbers_2
EndTime = Timer
vTimes(i) = EndTime - StartTime
Next i
Cells(2, 5).Resize(40, 1) = WorksheetFunction.Transpose(vTimes)
For i = 1 To 40
StartTime = Timer
FindNumbers_3
EndTime = Timer
vTimes(i) = EndTime - StartTime
Next i
Cells(2, 6).Resize(40, 1) = WorksheetFunction.Transpose(vTimes)
End Sub
Sub FindNumbers()
Dim i As Integer
Dim x As Long
Dim myCheck As Long
Dim NumStr()
For x = 209 To 999999 Step 210
myCheck = 0
If x Mod 2 = 1 Then myCheck = myCheck + 1
If x Mod 3 = 2 Then myCheck = myCheck + 1
If x Mod 4 = 3 Then myCheck = myCheck + 1
If x Mod 5 = 4 Then myCheck = myCheck + 1
If x Mod 6 = 5 Then myCheck = myCheck + 1
If x Mod 7 = 6 Then myCheck = myCheck + 1
If x Mod 8 = 7 Then myCheck = myCheck + 1
If x Mod 9 = 8 Then myCheck = myCheck + 1
If x Mod 10 = 9 Then myCheck = myCheck + 1
If myCheck = 9 Then
i = i + 1
ReDim Preserve NumStr(i)
NumStr(i) = x
End If
Next x
Range("A1").Resize(i, 1) = WorksheetFunction.Transpose(NumStr)
End Sub
Sub FindNumbers_2()
Dim i As Integer
Dim j As Integer
Dim x As Long
Dim myCheck As Long
Dim NumStr()
Dim Interval As Integer
' Calculate the Interval for all digits under 10, based on the minimum required # of primes
Interval = 2 * 2 * 2 * 3 * 3 * 5 * 7
' Decrement i to force the array to start at 0
i = -1
For x = Interval - 1 To 999999 Step Interval
myCheck = 0
For j = 2 To 10
If x Mod j = j - 1 Then myCheck = myCheck + 1
Next
If myCheck = 9 Then
i = i + 1
ReDim Preserve NumStr(i)
NumStr(i) = x
End If
Next x
Range("B1").Resize(i, 1) = WorksheetFunction.Transpose(NumStr)
End Sub
Sub FindNumbers_3()
Dim i As Long
Dim j As Integer
Dim Interval As Integer
Dim NumStr()
' Calculate the Interval for all digits under 10, based on the minimum required # of primes
Interval = 2 * 2 * 2 * 3 * 3 * 5 * 7
j = Int(999999 / Interval)
ReDim NumStr(j)
For i = 1 To j
NumStr(i) = (Interval * i) - 1
Next i
Range("B1").Resize(i, 1) = WorksheetFunction.Transpose(NumStr)
End Sub