You are on page 1of 3

EXP :

DATE :

AIM

ALGORITHM
OUTPUT
PROGRAM
def f2(n):
if n <= 1:
return n
else:
return(f2(n-1) + f2(n-2))

nterms = int(input("How many terms? "))

if nterms <= 0:
print("Plese enter a positive integer")
else:
print("Fibonacci sequence:")
for i in range(nterms):
print(f2(i))

RESULT

You might also like