primes = [2] counter = 1 while counter <= 2000000: counter += 2 for x in primes: if x * x > counter: # print(str(counter) + " found") primes += [counter] break elif counter % x == 0: break counter = 0 for x in primes: counter += x print(counter)