Created
November 26, 2018 19:05
-
-
Save dbc2201/2b9b430e7259a668f7fecdc44ae1ea8c to your computer and use it in GitHub Desktop.
a python program to print fibonacci series
This file contains 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_sequence(num1): | |
list1 = [] | |
if num1 == 0: | |
list1 = list1 | |
elif num1 == 1: | |
list1.append(0) | |
elif num1 == 2: | |
list1.extend([0, 1]) | |
else: | |
list1.extend([0, 1]) | |
for i in range(2, num1): | |
list1.append(list1[i - 2] + list1[i - 1]) | |
print(list1) | |
fibonacci_sequence(0) | |
fibonacci_sequence(2) | |
fibonacci_sequence(3) | |
fibonacci_sequence(8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment