Created
April 26, 2018 16:31
-
-
Save alexandre-spieser/37a3b4ed6bd292f4f3278d379293eb6a to your computer and use it in GitHub Desktop.
Project Euler Gists
This file contains hidden or 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
public void Euler1() { | |
var i = 1; | |
var sum = 0; | |
while(i < 1000) | |
{ | |
if(i % 3 == 0 || i % 5 == 0){ | |
sum += i; | |
} | |
i++; | |
} | |
Consolve.WriteLine(sum); | |
} | |
public void Euler2() | |
{ | |
var fibonacci = 0; | |
var prev = 1; | |
var last = 2; | |
var evenSum = 0; | |
while (fibonacci < 4000000) | |
{ | |
fibonacci = prev + last; | |
prev = last; | |
if (last % 2 == 0) | |
{ | |
evenSum += last; | |
} | |
last = fibonacci; | |
} | |
Console.WriteLine(evenSum); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment