// Q010: 142913828922; public static long Q010() { int n = 2000000; List <int> primes = NumberTheory.GetPrimesBelow(n); // 148933 primes; return(primes.Select(i => (long)i).Sum()); }
public void TestGetPrimesBelow() { int n = 10; List <int> primes = NumberTheory.GetPrimesBelow(n); Assert.That(primes.Count, Is.EqualTo(4)); Assert.That(primes.Sum(), Is.EqualTo(17)); n = 2000000; primes = NumberTheory.GetPrimesBelow(n); Assert.That(primes.Count, Is.EqualTo(148933)); Assert.That(primes.Select(i => (long)i).Sum(), Is.EqualTo(17)); }