Created
November 3, 2019 05:37
-
-
Save afaqk9394/b8a8b4f50330ee5b2cd6c7b705d15026 to your computer and use it in GitHub Desktop.
Fibonacci
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 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