Silly question

David C. Ullrich dullrich at sprynet.com
Sat Aug 22 01:32:41 CEST 2009


On Fri, 21 Aug 2009 14:45:55 -0500, David C Ullrich
<dullrich at sprynet.com> wrote:

>[...]
>
>Oops. Should have tested that a little more carefully
>before posting. No time to fix it right now, customer just
>got here. Let's just say we're looking for the primes
>between sqrt(n) and n...

from math import sqrt

def Primes(n):
  """Return a list of the primes < n"""
  sieve = range(n)
  for k in range(2,int(sqrt(n))+2):
      sieve[2*k::k] = [1]*((n-k-1)/k)
  return [p for p in sieve if p > 1]


David C. Ullrich

"Understanding Godel isn't about following his formal proof. 
That would make a mockery of everything Godel was up to."
(John Jones, "My talk about Godel to the post-grads."
in sci.logic.)



More information about the Python-list mailing list