Skip to content

Instantly share code, notes, and snippets.

@sizumita
Last active March 18, 2017 07:43
Show Gist options
  • Save sizumita/f979ace95c5ca609a5f2d59e249517a8 to your computer and use it in GitHub Desktop.
Save sizumita/f979ace95c5ca609a5f2d59e249517a8 to your computer and use it in GitHub Desktop.
Project Euler 2
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