Source Code
def fibonacci(n):
if n<=1:
return n
else:
return(fibonacci(n-1)+fibonacci(n-2))
num=int(input("How many terms you want to display: "))
for i in range(num):
print(fibonacci(i)," ", end=" ")
OUTPUT
How many terms you want to display: 9
0 1 1 2 3 5 8 13 21
No comments:
Post a Comment