Created
May 4, 2014 10:15
-
-
Save fivesmallq/6321e781023b1bab0ee7 to your computer and use it in GitHub Desktop.
This file contains 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 class Fibonacci { | |
public static void main(String[] args) { | |
int result = 0; | |
int first = 0, second = 1; | |
int sum = 0; | |
for (;;) { | |
result = first + second; | |
if (result > 4000000) { | |
break; | |
} | |
if (result % 2 == 0) { | |
sum = sum + result; | |
} | |
first = second; | |
second = result; | |
} | |
System.out.println(sum);//4613732 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment