Advertisement
rdrewd-facebook

find20primes.py

Sep 27th, 2014
1,791
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
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement