Skip to content

Instantly share code, notes, and snippets.

@JossWhittle
Created August 10, 2012 00:56
Show Gist options
  • Save JossWhittle/3309822 to your computer and use it in GitHub Desktop.
Save JossWhittle/3309822 to your computer and use it in GitHub Desktop.
int n = 0, n1 = 2, n2 = 1, r = 2;
while (n < 4000000) {
n = n1 + n2;
if (n % 2 == 0) {
r += n;
}
n2 = n1; n1 = n;
}
System.out.println(r);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment