Skip to content

Instantly share code, notes, and snippets.

@spmurrayzzz
Created March 24, 2013 00:17
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 spmurrayzzz/5229862 to your computer and use it in GitHub Desktop.
Save spmurrayzzz/5229862 to your computer and use it in GitHub Desktop.
Project Euler #25
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()
@spmurrayzzz
Copy link
Author

$ time python euler-25.py
4782

real 0m0.069s
user 0m0.060s
sys 0m0.008s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment