import math v = 0 for x in range(1, 1000001): for y in range (2, x): if (x % y == 0): break else: v += x print v print v