Created
March 24, 2013 00:17
-
-
Save spmurrayzzz/5229862 to your computer and use it in GitHub Desktop.
Project Euler #25
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
def fib(): | |
first = 0 | |
second = 1 | |
while True: | |
cached = first | |
first = first + second | |
second = cached | |
yield first | |
def main(): | |
for index, current in enumerate(fib()): | |
if len(str(current)) >= 1000: | |
answer = index + 1 | |
break | |
print(answer) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ time python euler-25.py
4782
real 0m0.069s
user 0m0.060s
sys 0m0.008s