SHARE
TWEET

find20primes.py

rdrewd-facebook Sep 27th, 2014 1,083 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. primes=[2]
  2. cand=3
  3. while len(primes) < 20:
  4.     for factor in primes:
  5.         if cand % factor == 0:
  6.             # Not a prime
  7.             break
  8.     else:
  9.        primes.append(cand)
  10.     cand += 2
  11. print primes
RAW Paste Data
Top