Fibonacci with python(using recursion )

# Python program to display the Fibonacci sequence up to n-th term using recursive functions

def recur_fibo(n):
“””Recursive function to
print Fibonacci sequence”””
if n <= 1:
return n
return(recur_fibo(n-1) + recur_fibo(n-2))

# take input from the user
nterms = int(input(“How many terms? “))

# check if the number of terms is valid
if nterms <= 0:
print(“Plese enter a positive integer”)
print(“Fibonacci sequence:”)
for i in range(nterms):

মন্তব্য করুন

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  পরিবর্তন )

Google photo

You are commenting using your Google account. Log Out /  পরিবর্তন )

Twitter picture

You are commenting using your Twitter account. Log Out /  পরিবর্তন )

Facebook photo

You are commenting using your Facebook account. Log Out /  পরিবর্তন )

Connecting to %s