Skip to content

Instantly share code, notes, and snippets.

@daGrevis
Created November 23, 2011 19:32
Show Gist options
  • Select an option

  • Save daGrevis/1389650 to your computer and use it in GitHub Desktop.

Select an option

Save daGrevis/1389650 to your computer and use it in GitHub Desktop.
Fibonacci sequence in Python 2.7 (almost 1st script in Python)
def fibonacci(n):
result = []
x, y = 0, 1
while x < n:
result.append(x)
x, y = y, y + x
return result
fibonacci(1000)
@daGrevis

Copy link
Copy Markdown
Author

Returns [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987].

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