Created
November 23, 2011 19:32
-
-
Save daGrevis/1389650 to your computer and use it in GitHub Desktop.
Fibonacci sequence in Python 2.7 (almost 1st script 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 fibonacci(n): | |
| result = [] | |
| x, y = 0, 1 | |
| while x < n: | |
| result.append(x) | |
| x, y = y, y + x | |
| return result | |
| fibonacci(1000) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Returns
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987].