Popular recipes tagged "primes" and "math"http://code.activestate.com/recipes/tags/primes+math/2010-07-27T01:57:20-07:00ActiveState Code RecipesFastest way to list all primes below N in python (Python)
2010-07-27T01:57:20-07:00robert.william.hankshttp://code.activestate.com/recipes/users/4174481/http://code.activestate.com/recipes/577331-fastest-way-to-list-all-primes-below-n-in-python/
<p style="color: grey">
Python
recipe 577331
by <a href="/recipes/users/4174481/">robert.william.hanks</a>
(<a href="/recipes/tags/fast/">fast</a>, <a href="/recipes/tags/fastest/">fastest</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/numbers/">numbers</a>, <a href="/recipes/tags/numpy/">numpy</a>, <a href="/recipes/tags/primes/">primes</a>, <a href="/recipes/tags/python/">python</a>).
Revision 6.
</p>
<p>I was looking for a fast way to list all primes below n,
so far i came up to this with the numpy solution the fastest.
It does primes up to 10e6 in 15ms in my old machine,
and it is capable of reaching 10e9. </p>
Sieve of Eratosthenes (Python)
2008-12-27T11:45:09-08:00Louis RIVIEREhttp://code.activestate.com/recipes/users/4035877/http://code.activestate.com/recipes/576596-sieve-of-eratosthenes/
<p style="color: grey">
Python
recipe 576596
by <a href="/recipes/users/4035877/">Louis RIVIERE</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/eratosthenes/">eratosthenes</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/primes/">primes</a>).
Revision 3.
</p>
<p>Returns primes < n.</p>