Popular recipes tagged "is_prime"http://code.activestate.com/recipes/tags/is_prime/2010-08-06T11:20:34-07:00ActiveState Code RecipesSome prime generation algorithms. (Python)
2010-08-06T11:20:34-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/577329-some-prime-generation-algorithms/
<p style="color: grey">
Python
recipe 577329
by <a href="/recipes/users/4174477/">Thomas Lehmann</a>
(<a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/is_prime/">is_prime</a>, <a href="/recipes/tags/prime/">prime</a>, <a href="/recipes/tags/primes/">primes</a>).
Revision 4.
</p>
<p>Basic idea was to see the difference between different prime algorithms in time. Also they are not perfect the output shows that really higher numbers let grow the difference why I have separated this into functions to make it visible. I add this here because I have been missing this very often when I have been searching for algorithms.</p>
<ul>
<li>The 'is_prime' is a well known way of checkin for a number being prime or not.</li>
<li>The sieve of Erastothenes is simply to strike out multiples of a given value; the primes will remain.</li>
<li>the function 'profile' is a decorator for functions measuring the execution time</li>
<li>Some information are in the comments of the code</li>
</ul>