Created
June 27, 2017 17:13
-
-
Save omalley/03cf5bd2cc9b15c6344e6ff3937ee4aa to your computer and use it in GitHub Desktop.
Fibonacci in python
This file contains hidden or 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(n): | |
... last = 0 | |
... current = 1 | |
... for i in range(n): | |
... (last, current) = (current, last + current) | |
... return current | |
... | |
>>> fib(3) | |
3 | |
>>> fib(100) | |
573147844013817084101 | |
>>> fib(30) | |
1346269 | |
>>> fib(1000) | |
70330367711422815821835254877183549770181269836358732742604905087154537118196933579742249494562611733487750449241765991088186363265450223647106012053374121273867339111198139373125598767690091902245245323403501 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment