Think about Loose Coupling | |
PerlMonks |
Re^2: ulam's spiral too slowby grinder (Bishop) |
on Apr 15, 2007 at 20:28 UTC ( [id://610224]=note: 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 Section
Seekers of Perl Wisdom
|
|