n=int (enter the N value of the "Fibonacci sequence F(N)" --> : ")))
def fibo(n):
# Recursive functions require escape conditions.
if n < 3 :
return 1
else :
return fibo(n-2) + fibo(n-1)
# Find the Fibonacci sequence to index n
def fibo_list(n):
for i in range(n):
print(fibo(i), end= " ")
print(fibo(n))
I even used a recursive function to make the Fibonacci sequence count
For example, if you set the value of n to 7, at the end,
F(7) = 13
What should I do to make F(n) appear in front of the value in this way?
The title is about the Fibonacci sequence recursive function, and in fact, what you're asking is how to use Python prints!
# Method 1
print "fibo(1) =", fibo(1)
# Method 2
print("fibo(7) = " + str(fibo(7)))
© 2024 OneMinuteCode. All rights reserved.