The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
而我的回答是:項目歐拉數10#
bool IsRishoni;
int soap = 0;
for (int i = 3; i < 2000000; i++)
{
IsRishoni = true;
for (int a = 2; (a <= Math.Sqrt(i)) && (IsRishoni); a++)
{
if (i % a == 0)
IsRishoni = false;
}
if (IsRishoni)
{
soap = i + soap;
}
}
Console.WriteLine(soap + 2);
Console.ReadLine();
這是爲什麼不工作?我得到的答案是1179908154 ...請幫助。
你應該得到什麼答案? – 2012-04-28 08:00:53
他還不知道答案(這是他試圖解決的問題!),我不會破壞它,但答案是<100000 – inspite 2012-04-28 08:02:41
@ DD59不,它比這更大。 – 2012-04-28 08:04:19