Created
July 11, 2012 17:24
-
-
Save jletourneau/3091865 to your computer and use it in GitHub Desktop.
Demo code sample
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
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