View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default How to generate a list of prime number?

Dana

Thanks for that you are of course correct. It gets very slow as numbers get
large so another improvement is to loop from2

For x= 2 to 10000
this allows the test for <2 to be eliminated
If (x < 2 And x Mod 2 = 0) Or x < Int(x) Then GoTo 100

Mike
"Dana DeLouis" wrote:

For x = 1 To 10000
Dim i As Long


Could I suggest moving the Dim statement to the beginning so that it's
called only once?

Dim i As Long
For x = 1 To 10000
--
HTH
Dana DeLouis

<snip