Skip to content
Home » Python Programs » Fibonacci Series in Python Using Recursion Function

Fibonacci Series in Python Using Recursion Function

Fibonacci series in python using recursion function. In this program, we can execute the Fibonacci series in python for beginners to execute the Fibonacci using a recursion function.

If Else Definition in Python

An if-else clause The true or false value of an expression is determined by a Python statement. The “if” statement is executed if a condition is true. If not, the “else” statement is executed. If statements in Python enable programmers to manage the flow of their programming.

Recursion Function in Python

Functions that call themselves are known as recursive functions. There are two parts to it: the base case and the recursive case. The base case is the situation that will bring the recursion to an end. The section of the function that calls on itself is called the recursive case. By using the recursion concept we have executed the fibonacci series in python using recursion function

Fibonacci Series in Python

The Fibonacci sequence is a set of numbers in which each successive number is the sum of the two preceding numbers. The series begins at 0 and 1 and continues indefinitely: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so on. A mathematical equation can be used to describe the Fibonacci sequence: Xn+2= Xn+1 + Xn.

Fibonacci Series in Python Using Recursion Function

def Fibonacci(n):
    if n<= 0:
        print("Wrong Input Value")
    elif n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return Fibonacci(n-1)+Fibonacci(n-2)
print(Fibonacci(5))

Output:

3