- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Python Program to Display Fibonacci Sequence Using Recursion

When it is required to print the fibonacci sequence using the method of recursion, a method can be declared that calls the same method again and again until a base value is reached.

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 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 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.

If the value is less than one, it is returned as output.

Otherwise the same method is called again and again until a base condition is reached.

The number of terms in the Fibonacci sequence is defined.

The method is called, and the output is displayed on the console.

- Related Questions & Answers
- Python Program to Find the Fibonacci Series Using Recursion
- Python Program to Find the Fibonacci Series without Using Recursion
- C++ Program to Find Fibonacci Numbers using Recursion
- Fibonacci series program in Java using recursion.
- How to print the Fibonacci Sequence using Python?
- Fibonacci series program in Java without using recursion.
- 8085 program to generate Fibonacci sequence
- 8086 program to generate Fibonacci Sequence
- C++ Program to Display Fibonacci Series
- Java Program to Display Fibonacci Series
- Python Program to Display all the Nodes in a Linked List using Recursion
- Finding Fibonacci sequence in an array using JavaScript
- The Fibonacci sequence in Javascript
- Fibonacci like sequence in JavaScript
- Python Program to Display the Nodes of a Linked List in Reverse using Recursion

Advertisements