Program to display Fibonacci sequence using function

In Python, We can display Fibonacci sequence using function,

Program
Def fib(n):
if n<=1:
return n
else
return (fib(n-1)+fib(n-2)

n1 = int(input(" Fibonacci number")
if n1 <=0:
print("Enter a positive integer")
else:
for i in rang(n1)
print(fib(i))

Leave a Reply