Good ideas and conversation. No ads, no tracking. Login or Take a Tour!
Generating all primes is just as easy as testing for primes: def is_prime(n): for m in range(2,int(math.sqrt(n))+1): if n%m == 0: return False return True def primes(): n = 2 while True: if is_prime(n): yield n n += 1 for p in primes(): print p it's just that we don't have useful ways to generate primes. import math