solve problem 10
This commit is contained in:
parent
261511f44c
commit
e7faccb57d
14
Program.cs
14
Program.cs
@ -57,6 +57,7 @@ namespace Euler {
|
||||
primes.Add(2);
|
||||
for (int i = 3; i <= num; i += 2) {
|
||||
if (IsPrime(i, primes)) {
|
||||
WriteLine(i);
|
||||
primes.Add(i);
|
||||
}
|
||||
}
|
||||
@ -212,8 +213,19 @@ namespace Euler {
|
||||
return 0;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
static long Problem10() {
|
||||
List<long> primes = PrimesUpThrough(2_000_000);
|
||||
long sum = 0;
|
||||
foreach (long prime in primes) {
|
||||
sum += prime;
|
||||
}
|
||||
Assert.Equal(142913828922, sum);
|
||||
return sum;
|
||||
}
|
||||
|
||||
static void Main(string[] args) {
|
||||
WriteLine(Problem9());
|
||||
WriteLine(Problem10());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user