Created
July 21, 2015 17:26
-
-
Save BradEwing/7c5a0496c0c3e26d7264 to your computer and use it in GitHub Desktop.
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
| // Solution to Project Euler Problem 2, | |
| // https://projecteuler.net/problem=2 | |
| fn main() { | |
| let mut i = 1; | |
| let mut j = 2; | |
| let mut tmp; | |
| let mut result = 0; | |
| while j < 4000000 { | |
| if j%2 == 0 { result += j } | |
| tmp = j; | |
| j = i + j; | |
| i = tmp; | |
| } | |
| println!("{}", result); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment