Advertisement
Guest User

Untitled

a guest
Dec 26th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. def isprime(i, primes):
  2.     for m in primes:
  3.         if i % m == 0:
  4.             return False
  5.     return True
  6.  
  7. def fprimes(n):
  8.     primes = [2, 3]
  9.  
  10.     for i in xrange(5, n+1, 2):
  11.         if isprime(i, primes):
  12.             primes.append(i)
  13.     return primes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement