
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python Program to Find the Fibonacci Series Using Recursion
When it is required to find the Fibonacci sequence using the method of recursion, a method named ‘fibonacci_recursion’ is defined, that takes a value as parameter. It is called again and again by reducing the size of the input.
Below is a demonstration of the same:
Example
def fibonacci_recursion(my_val): if my_val <= 1: return my_val else: return(fibonacci_recursion(my_val-1) + fibonacci_recursion(my_val-2)) num_terms = 12 print("The number of terms is ") print(num_terms) if num_terms <= 0: print("Enter a positive integer...") else: print("The Fibonacci sequence is :") for i in range(num_terms): print(fibonacci_recursion(i))
Output
The number of terms is 12 The Fibonacci sequence is : 0 1 1 2 3 5 8 13 21 34 55 89
Explanation
A method named ‘fibonacci_recursion’ is defined that takes a value as parameter.
The base conditions are defined.
The method is called again and again until the output is obtained.
Outside the method, the number of terms are defined and displayed on the console.
The numbers within the range are iterated, and the recursive method is called.
The relevant output is displayed on the console.
- Related Articles
- Python Program to Find the Fibonacci Series without Using Recursion
- Fibonacci series program in Java using recursion.
- Fibonacci series program in Java without using recursion.
- Python Program to Display Fibonacci Sequence Using Recursion
- C++ Program to Find Fibonacci Numbers using Recursion
- How to get the nth value of a Fibonacci series using recursion in C#?
- Find fibonacci series upto n using lambda in Python
- Program to find Fibonacci series results up to nth term in Python
- C++ Program to Display Fibonacci Series
- Java Program to Display Fibonacci Series
- Swift Program to Display Fibonacci Series
- Haskell Program to Display Fibonacci Series
- Kotlin Program to Display Fibonacci Series
- Python Program to Find the Product of two Numbers Using Recursion
- Python Program to Find the Length of a List Using Recursion

Advertisements