Skip to content

Instantly share code, notes, and snippets.

@luc99a
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luc99a/8820410a7b18b7dba0f2 to your computer and use it in GitHub Desktop.
Save luc99a/8820410a7b18b7dba0f2 to your computer and use it in GitHub Desktop.
def fib(n):
sequence = [1, 1]
next_number = 2
while next_number <= n:
sequence.append(next_number)
next_number = sequence[len(sequence) - 1] + sequence[len(sequence) - 2]
return sequence
def get_evens(l):
ret = []
for i in l:
if i % 2 == 0:
ret.append(i)
return ret
def sum_list(l):
total = 0
for i in l:
total += i
return total
print(sum_list(get_evens(fib(4000000))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment