Created
May 5, 2014 02:10
-
-
Save Ahmed-Fawzy/8f166b29974c9532325b to your computer and use it in GitHub Desktop.
Project Euler - Problem 2
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
#!/usr/bin/python | |
End = 4000000 | |
Sum = 2 | |
back = 1 | |
current = 2 | |
def is_even(n): | |
return n % 2 == 0 | |
while True : | |
num = back + current | |
if num < End : | |
if is_even(num) == True : | |
Sum += num | |
else: | |
break | |
back = current | |
current = num | |
print Sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment