-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (35 loc) · 714 Bytes
/
Program.cs
File metadata and controls
40 lines (35 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
namespace Euler_Problem_0000002
{
internal class Program
{
private static void Main()
{
var validIntList = new List<Int64>();
Int64 j = 0;
Int64 i = 1;
while (i < 4000000)
{
if (IsEven(i))
{
validIntList.Add(i);
}
Int64 g = i;
i = j + i;
j = g;
}
if (validIntList.Count > 0)
{
Int64 total = validIntList.Aggregate<long, long>(0, (current, l) => current + l);
Console.WriteLine(total);
}
Console.ReadLine();
}
private static bool IsEven(Int64 i)
{
return i%2 == 0;
}
}
}