Skip to content

Instantly share code, notes, and snippets.

@BradEwing
Created July 21, 2015 17:26
Show Gist options
  • Select an option

  • Save BradEwing/7c5a0496c0c3e26d7264 to your computer and use it in GitHub Desktop.

Select an option

Save BradEwing/7c5a0496c0c3e26d7264 to your computer and use it in GitHub Desktop.
// 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