Last active
March 18, 2017 07:43
-
-
Save sizumita/f979ace95c5ca609a5f2d59e249517a8 to your computer and use it in GitHub Desktop.
Project Euler 2
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
fibs = [1,2] | |
index = 0 | |
while True: | |
nextIndex = index + 1 | |
fib = fibs[index] | |
nextFib = fibs[nextIndex] | |
newFib = fib + nextFib | |
if newFib > 4000000: | |
break | |
fibs = fibs + [newFib] | |
index = index + 1 | |
total = 0 | |
for fib in fibs: | |
if fib % 2 == 0: | |
total = total + fib | |
print total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment