Print Fibonacci Series in reverse order using Recursion Last Updated : 16 May, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Given an integer n, the task is to print the first n terms of the Fibonacci series in reverse order using Recursion.Examples:Input: N = 5Output: 3 2 1 1 0Explanation: First five terms are - 0 1 1 2 3. Input: N = 10Output: 34 21 13 8 5 3 2 1 1 0Approach: The idea is to use recursion in a way that keeps calling the same function again till N is greater than 0 and keeps on adding the terms and after that starts printing the terms. Follow the steps below to solve the problem:Define a function fibo(int N, int a, int b) whereN is the number of terms anda and b are the initial terms with values 0 and 1.If N is greater than 0, then call the function again with values N-1, b, a+b.After the function call, print a as the answer.Below is the implementation of the above approach. C++ // C++ program for the above approach #include <bits/stdc++.h> using namespace std; // Function to print the fibonacci // series in reverse order. void fibo(int n, int a, int b) { if (n > 0) { // Function call fibo(n - 1, b, a + b); // Print the result cout << a << " "; } } // Driver Code int main() { int N = 10; fibo(N, 0, 1); return 0; } Java // Java program for the above approach import java.util.*; public class GFG { // Function to print the fibonacci // series in reverse order. static void fibo(int n, int a, int b) { if (n > 0) { // Function call fibo(n - 1, b, a + b); // Print the result System.out.print(a + " "); } } // Driver Code public static void main(String args[]) { int N = 10; fibo(N, 0, 1); } } // This code is contributed by Samim Hossain Mondal. Python # Python program for the above approach # Function to print the fibonacci # series in reverse order. def fibo(n, a, b): if (n > 0): # Function call fibo(n - 1, b, a + b) # Print the result print(a, end=" ") # Driver Code if __name__ == "__main__": N = 10 fibo(N, 0, 1) # This code is contributed by Samim Hossain Mondal. C# // C# program for the above approach using System; class GFG { // Function to print the fibonacci // series in reverse order. static void fibo(int n, int a, int b) { if (n > 0) { // Function call fibo(n - 1, b, a + b); // Print the result Console.Write(a + " "); } } // Driver Code public static void Main() { int N = 10; fibo(N, 0, 1); } } // This code is contributed by Samim Hossain Mondal. JavaScript <script> // Javascript program for the above approach // Function to print the fibonacci // series in reverse order. function fibo(n, a, b) { if (n > 0) { // Function call fibo(n - 1, b, a + b); // Print the result document.write(a + " "); } } // Driver Code let N = 10; fibo(N, 0, 1); // This code is contributed by Samim Hossain Mondal. </script> Output34 21 13 8 5 3 2 1 1 0 Time Complexity: O(N)Auxiliary Space: O(N) Comment More infoAdvertise with us Next Article Print Fibonacci Series in reverse order using Recursion R rohit5swd Follow Improve Article Tags : Pattern Searching Mathematical Competitive Programming Recursion DSA Fibonacci Reverse +3 More Practice Tags : FibonacciMathematicalPattern SearchingRecursionReverse +1 More Similar Reads Introduction to Recursion The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called a recursive function. A recursive algorithm takes one step toward solution and then recursively call itself to further move. The algorithm stops once we reach the solution 14 min read What is Recursion? Recursion is defined as a process which calls itself directly or indirectly and the corresponding function is called a recursive function.Example 1 : Sum of Natural Numbers Let us consider a problem to find the sum of natural numbers, there are several ways of doing that but the simplest approach is 8 min read Difference between Recursion and Iteration A program is called recursive when an entity calls itself. A program is called iterative when there is a loop (or repetition).Example: Program to find the factorial of a number C++ // C++ program to find factorial of given number #include<bits/stdc++.h> using namespace std; // ----- Recursion 6 min read Types of Recursions What is Recursion? The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called a recursive function. Using recursive algorithm, certain problems can be solved quite easily. Examples of such problems are Towers of Hanoi (TOH), Inord 15+ min read Finite and Infinite Recursion with examples The process in which a function calls itself directly or indirectly is called Recursion and the corresponding function is called a Recursive function. Using Recursion, certain problems can be solved quite easily. Examples of such problems are Towers of Hanoi (TOH), Inorder/Preorder/Postorder Tree Tr 6 min read What is Tail Recursion Tail recursion is defined as a recursive function in which the recursive call is the last statement that is executed by the function. So basically nothing is left to execute after the recursion call.For example the following function print() is tail recursive.C++// An example of tail recursive funct 7 min read What is Implicit recursion? What is Recursion? Recursion is a programming approach where a function repeats an action by calling itself, either directly or indirectly. This enables the function to continue performing the action until a particular condition is satisfied, such as when a particular value is reached or another con 5 min read Why is Tail Recursion optimization faster than normal Recursion? What is tail recursion? Tail recursion is defined as a recursive function in which the recursive call is the last statement that is executed by the function. So basically nothing is left to execute after the recursion call. What is non-tail recursion? Non-tail or head recursion is defined as a recur 4 min read Recursive Functions A Recursive function can be defined as a routine that calls itself directly or indirectly. In other words, a recursive function is a function that solves a problem by solving smaller instances of the same problem. This technique is commonly used in programming to solve problems that can be broken do 4 min read Difference Between Recursion and Induction Recursion and induction are fundamental ideas in computer science and mathematics that might be regularly used to solve problems regarding repetitive structures. Recursion is a programming technique in which a function calls itself to solve the problem, whilst induction is a mathematical proof techn 4 min read Like