project-euler/problem10.py

26 lines
380 B
Python
Raw Normal View History

2017-12-21 18:33:30 +00:00
'''nums = [i for i in range(2,20000)]
primes = 0
while len(nums) > 0:
prime = nums.pop(0)
print(prime)
primes += prime
for n in nums:
if n % prime == 0:
nums.remove(n)'''
primes = []
for n in range(2,20000):
for p in primes:
if n % p == 0:
break
if n < p*p:
primes.append(n)
break
else:
primes.append(n)
print(sum(primes))