good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
you only need to be looking at all values between 2 and sqrt(N) I was about to tick you off, for not suggesting examining only odd numbers, but in fact your code does exactly that. Nonetheless, the fact that you are caching previously discovered primes admits an elegant optimisation: you only need to be looking at all prime numbers between 2 and sqrt(N). Retooling your most excellent code is left as an exercise to the reader :) • another intruder with the mooring in the heart of the Perl In reply to Re^2: ulam's spiral too slow
by grinder
|
|