Python program to display the Fibonacci sequence using a recursive function in python. Below is the code snippet,
# Fibonacci sequence in Python
input_terms = int(input("Enter terms? "))
# Recursive function for fibonacci
def recursive_fibonacci(n):
if n <= 1:
return n
else:
return recursive_fibonacci(n - 1) + recursive_fibonacci(n - 2)
# Check the input value if it is an integer or not
if input_terms <= 0:
print("Please enter only a positive integer values")
else:
print("Fibonacci sequence numbers are:")
for i in range(input_terms):
print(recursive_fibonacci(i))
Output:
Enter terms? 10
Fibonacci sequence numbers are:
0
1
1
2
3
5
8
13
21
34
Comments (0)