Skip to content

Instantly share code, notes, and snippets.

@afaqk9394
Created November 3, 2019 05:37
Show Gist options
  • Select an option

  • Save afaqk9394/b8a8b4f50330ee5b2cd6c7b705d15026 to your computer and use it in GitHub Desktop.

Select an option

Save afaqk9394/b8a8b4f50330ee5b2cd6c7b705d15026 to your computer and use it in GitHub Desktop.
Fibonacci
def fib1(n): # print Fibonacci series up to n
x, y = 0, 1
while x < n:
print(x, end=' ')
x, y = y, x+y
print()
def fib2(n): # return Fibonacci series up to None
result = []
x, y = 0, 1
while x < n:
result.append(x)
x, y = y, x+y
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment