Advertisement
rdrewd-facebook

find20primes.py

Sep 27th, 2014
2,127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment
Advertisement