feat(solution): problem #10
parent
237c116253
commit
4843a4fffc
|
|
@ -0,0 +1,18 @@
|
||||||
|
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))
|
||||||
Loading…
Reference in New Issue