Skip to content

Instantly share code, notes, and snippets.

@EslaMx7
Last active December 26, 2018 06:16
Show Gist options
  • Save EslaMx7/8728176 to your computer and use it in GitHub Desktop.
Save EslaMx7/8728176 to your computer and use it in GitHub Desktop.
Project Euler Problem 2 Solution with C#
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