Skip to content

Instantly share code, notes, and snippets.

@jletourneau
Created July 11, 2012 17:24
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 jletourneau/3091865 to your computer and use it in GitHub Desktop.
Save jletourneau/3091865 to your computer and use it in GitHub Desktop.
Demo code sample
import utils
@utils.memoize
def fib(n):
if n < 3:
return 1
return fib(n - 2) + fib(n - 1)
(i, sum) = (1, 0)
while True:
f = fib(i)
if f >= 4000000:
break
if f % 2 == 0:
sum += fib(i)
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment