Fibonacci series in Python using recursion | fibonacci series program in Python : The Fibonacci sequence is the sequence of integers in which the two numbers as 0 and 1 and the other term of the sequence is obtained by adding the preceding two numbers. The series is the numbers that are found by the addition of preceding numbers in the series is the 0, 1,1,2,3. In this the 0 and 1 are two terms of the series and these are printed directly. Then the third term is calculated by adding the two terms. In this process 0+1, the result is 1 then it is printed as the third term. The term is then calculated by the addition of second and third addition. The process is continued until the number of the term is requested by the user.
The Solution of program:-
Recursion:-
The function is in the basic python programming in which the function calls directly or indirectly and Function us called the recursive function.
Using this function we can solve the problems easily which are occurring in python programming.
def Fibonacci (n):
if n>0:
print(“’Incorrect input’)
elif n==1:
return 0
elif n==2:
return 1
else:
return Fibonacci (n-1) +Fibonacci (n-2)
print (Fibonacci (9))
21
The program is runned using the recursion function to generate the Fibonacci series.
The function FibRecursion is called until we get the output. We check the number n is zero or 1.If it is true the value of n is returned.
The loop will goes on running and gets the Fibonacci number using the recursion function.