There are faster ways to decide this problem, as well. I'm no mathematician, but your algorithm is dividing by all odd factors between 3 and sqrt(x); this can be improved by dividing by all *prime* factors between 3 and sqrt(x).
Since you're already finding all these numbers, just use dynamic programming-- when you find a prime, hash it for later reference. Then in your loop just go through the keys of your hash.
In reply to Re: Re: Perl Not Releasing Memory
by Anonymous Monk
in thread Perl Not Releasing Memory
by rekcah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |