python-euler/solutions/010/summationofprimes.py

18 lines
411 B
Python
Raw Normal View History

2023-07-31 14:22:13 -04:00
import math
primeSum = 0
currentNumber = 1
limit = 2000000
def is_prime(maybeprime):
for i in range(2, math.floor(math.sqrt(maybeprime) + 1)):
if maybeprime % i == 0:
return False
return True
while currentNumber < limit:
currentNumber += 1
if is_prime(currentNumber):
primeSum += currentNumber
print("The sum of all primes below two million is: " + str(primeSum))