1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import math primes = [2] print(2, end=' ') count = 1; for i in range(3, 200000): for j in primes: if i % j == 0: break elif j > math.sqrt(i): count += 1 print(i, end=' ') if count % 5 == 0: print() primes.append(i) break print()