Last active
December 26, 2018 06:16
-
-
Save EslaMx7/8728176 to your computer and use it in GitHub Desktop.
Project Euler Problem 2 Solution with C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsolesTests | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int First = 0, Next = 1, Result = 0,Sum=0; | |
while (Result < 4000000) | |
{ | |
Result = First + Next; | |
First = Next; | |
Next = Result; | |
if (Result % 2 == 0) | |
{ | |
Sum += Result; | |
Console.Write(Result + ", "); | |
} | |
} | |
Console.WriteLine("\nSum :"+Sum); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment