問題
Calculate the sum of all the primes below two million.
英語
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
http://projecteuler.net/index.php?section=problems&id=10
日本語
10以下の素数の和は2 + 3 + 5 + 7 = 17である.
200万以下の全ての素数の和を計算しなさい.注意: この問題は最近変更されました. 正しいパラメータを使用しているか確認してください。
http://odz.sakura.ne.jp/projecteuler/index.php?Problem%2010
解説
Primeクラスを使ってもいいけど速度が非常に遅いので
エラトステネスの篩で2百万以下の素数表を生成して総和。
ソースコード1の方は普通に実装したものだが高速。
ソースコード2の方は短くかけるけど非常に遅い。
だから1の方が便利