import gmpy2 n = 2 while n <= 1000: print n n = gmpy2.next_prime(n)