搞什么啊,csdn一直发不了博客啊,郁闷! using System; using System.Collections.Generic; using System.Linq; using System.Text; //输出结果: //142913828922 //The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. //Find the sum of all the primes below two million. namespace Problem10 { class Program { static void Main(string[] args) { long sum = 0; int i = 2; while (true) { if (i >= 2000000) { break; } if (IsPrime(i) ) { sum += i; } i++; } Console.WriteLine("{0}", sum); } public static bool IsPrime(long l) { for (long i = 2; i < (long)Math.Sqrt(l) + 1; i++) { if (l % i == 0) { return false; } } return true; } } }