Hier mit 6,75 s.
Private Sub CommandButton1_Click()
Dim x1, x2, ti, i, max, pri
i = 2
ti = Timer
max = 1000000
Cells(1, 1) = 2
For x1 = 3 To max Step 2
pri = True
For x2 = 3 To Sqr(x1) + 1 Step 2
If x1 Mod x2 = 0 Then
pri = False
Exit For
End If
Next x2
If pri Then
Cells(i, 1) = x1
i = i + 1
End If
Next x1
MsgBox Timer - ti
End Sub
|