よしたく blog

ほぼ週刊で記事を書いています

【Project Euler】Problem 10 Summation of primesをPythonで解く

この問題をPythonで解いた。

#10 Summation of primes - Project Euler

日本語の問題文はこちら

10以下の素数の和は 2 + 3 + 5 + 7 = 17 である. 200万以下の全ての素数の和を求めよ.

Problem 10 - PukiWiki

from sympy import isprime

result = 0

for num in range(2, 2000000):
    if isprime(num):
        result += num
print(result)