Fibonacci numbers are often used as an intro into recursion because they are naturally recursive. In fact, implementing them recursively is trivial in any language. On a side note, it is usually not the best way to implement Fibonacci sequence for practical purposes.

By definition, Fib(X) = Fib(X - 1) + Fib(X - 2). This is recursion right there. The only thing which is missing is how we stop the recursion, and we know that Fib(0) is the same as Fib(1) and is 1.

How do we translate this to the C language? Very simple, almost one-to-one mapping!

unsigned int fib(unsigned int k) {
    // First, check our exit (stop) conditions:
    if (k == 0 || k == 1) return 1;

    // Now recursive part  
    return fib(k - 1) + fib(k - 2);
}
Answer from SergeyA on Stack Overflow
🌐
TutorialsPoint
tutorialspoint.com › data_structures_algorithms › fibonacci_recursive_program_in_c.htm
Fibonacci Recursive Program in C
#include <stdio.h> int factorial(int n) { //base case if(n == 0) { return 1; } else { return n * factorial(n-1); } } int fibbonacci(int n) { if(n == 0){ return 0; } else if(n == 1) { return 1; } else { return (fibbonacci(n-1) + fibbonacci(n-2)); } } ...
🌐
GeeksforGeeks
geeksforgeeks.org › c language › c-fibonacci-series
C Program to Print Fibonacci Series - GeeksforGeeks
We can also print Fibonacci series using recursion. This method is as much as popular as iteration method. We will use a function that prints the first two terms, and then call the recursive function that handles the rest of the terms.
Published   July 23, 2025
Discussions

Fibonacci sequence using recursion in C - Stack Overflow
I am trying (and failing) to print the fibonacci sequence using recursion. I'm sure this is very very basic but I can't seem to get it. Please tell me what I am doing wrong, thanks! #include More on stackoverflow.com
🌐 stackoverflow.com
Fibonacci without recursion in C: stack smashed?
To all following commenters: please, do not bring up the old circlejerk jokes/memes about recursion ("Understanding recursion...", "This is recursion...", etc.). We've all heard them n+2 too many times. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/learnprogramming
11
4
November 12, 2021
Can Fibonacci numbers be calculated using recursion in O(N) without memo?
The iterative solution always stores two variables. Thus you can model the recursive solution like this (excluding the base case):  fib(n) {     (a, b) = fib(n-1)     return (b, a + b) } More on reddit.com
🌐 r/compsci
19
11
July 3, 2024
[C++] Converting Fibonacci from Recursion to Tail Recursion

Tail recursion requires that recursive calls you make are immediately returned, and that you don't do any processing of the return value of a recursive call.

In your regular function, fib() is called twice and added together. Think about how you would modify the signature of fib so you only have to call it once (and as a consequence, the runtime would be made linear instead of exponential).

Once that's done, it's easy to make it tail recursive.

edit: I originally said there can be only one recursive call and it has to be at the bottom to make a function tail recursive which is incorrect. The only requirement is that a recursive call is returned immediately.

More on reddit.com
🌐 r/learnprogramming
11
5
September 27, 2012
People also ask

Is there any disadvantage of using the recursive method in calculating the Fibonacci series in C?
Yes. There is one major disadvantage of generating the Fibonacci series using recursion in C. Recursion involves calling a function repeatedly in a program that may eventually lead to stack overflow if we try to calculate some larger terms in the Fibonacci series. We can avoid this. We can use Memoization. It is the process in which we store the Fibonacci series calculated in the array and then use it for lookup. This way, the recursive algorithm’s running time gets reduced a lot. It is very important to do, as this series has a wide application in the field of Computer Science as well as Math
🌐
byjus.com
byjus.com › gate › fibonacci-series-using-recursion-in-c
Fibonacci Series Using Recursion in C
What’s the easiest way to understand and calculate the Fibonacci series in the C language?
In a Fibonacci number series, the next number in line is basically the sum of the last two numbers (preceding numbers). The first two numbers are always 1 and 0 in the series. Thus, it goes like 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, etc.
🌐
byjus.com
byjus.com › gate › fibonacci-series-using-recursion-in-c
Fibonacci Series Using Recursion in C
Is zero (0) considered a Fibonacci number?
Yes, zero is the very first number in a Fibonacci series by default. Thus, we consider it as a Fibonacci number.
🌐
byjus.com
byjus.com › gate › fibonacci-series-using-recursion-in-c
Fibonacci Series Using Recursion in C
🌐
BYJUS
byjus.com › gate › fibonacci-series-using-recursion-in-c
Fibonacci Series Using Recursion in C
February 16, 2024 - In this case, the calling of the Fibonacci function will occur recursively unless the program generates a proper output. Firstly, in the function, the program checks if the available number m in the program is one or zero.
🌐
Scaler
scaler.com › home › topics › fibonacci series program in c
Fibonacci Series Program in C | Scaler Topics
January 5, 2024 - We will write a function that will take an integer as an input (the position in the Fibonacci series whose element we want to display) and will return the element at that position · In this function, we will have an if-else-if ladder · If ...
🌐
Internshala
trainings.internshala.com › home › programming › c and c++ › fibonacci series program in c: using recursion, function and more
Fibonacci Series In C: Using Recursion, Function And More
January 16, 2024 - For example, to generate the 5th number in the sequence, a recursive function would call itself to generate the 3rd number and the 4th number, and then add them together. Here’s a C program that calculates the Fibonacci series using recursion in C:
Find elsewhere
🌐
NxtWave
ccbp.in › blog › articles › c-program-for-fibonacci-series
C Program for Fibonacci Series With Examples
Now let’s look at the Fibonacci series in c recursion. This program prints the Fibonacci series using recursion. The printFib() function handles edge cases for n less than 3 and prints the first two terms for larger values.
Top answer
1 of 2
4

Fibonacci numbers are often used as an intro into recursion because they are naturally recursive. In fact, implementing them recursively is trivial in any language. On a side note, it is usually not the best way to implement Fibonacci sequence for practical purposes.

By definition, Fib(X) = Fib(X - 1) + Fib(X - 2). This is recursion right there. The only thing which is missing is how we stop the recursion, and we know that Fib(0) is the same as Fib(1) and is 1.

How do we translate this to the C language? Very simple, almost one-to-one mapping!

unsigned int fib(unsigned int k) {
    // First, check our exit (stop) conditions:
    if (k == 0 || k == 1) return 1;

    // Now recursive part  
    return fib(k - 1) + fib(k - 2);
}
2 of 2
2

Almost every recursion function contains two part : the particular part and then the recursive part.

So to write this function your algorithm will look like this

 if (condition_separate_particular_part) 
    {
        //here the code for part
    }
else 
    {
         //the recursive part 
    }

Now to determine the recursive part you will try to find how to explain the element "i" using it's predecessor elements "i-1" "i-2" ....

Like this it will be easy for you every time.

Note that sometimes it's useful to start to find iterative way to make it easy for your self.

I'm damn sure that you are new so that's why you feel lost a bit. But trust me you will habit soon if you exercise more. Try and you gonna see. ;).

Let me know if you find difficulties to find more exercises/examples. I will try to help you :).

Here is and example. Just type Exercise with solution for recursive functions on C and you will find a lot to exercise ;).

Now here both recursive and iterative code

Recursive

 int fib(int n){
      if (n < 2) // here is particular case
        return n;
      else  // here is the recursion 
        return fib(n-1) + fib(n-2);
    }

printf("%d\n", fib(10));

iterative

int fib(int n) {
  int first = 0, second = 1;

  int tmp;
  while (n--) {
    tmp = first+second;
    first = second;
    second = tmp;
  }
  return first;
}
🌐
Unstop
unstop.com › home › blog › fibonacci series using recursion in c (+detailed examples)
Fibonacci Series Using Recursion In C (+Detailed Examples)
May 13, 2025 - To find the Fibonacci series using recursion in C, we break the series into individual elements and recursively calculate them. We can also do this using loops.
🌐
Simplilearn
simplilearn.com › home › resources › software development › fibonacci series in c using recursion
Fibonacci Series in C Using Recursion
April 21, 2025 - The Fibonacci sequence is a set of numbers that is generated by adding the two numbers before it. Zero and one are the first two terms, respectively.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
DataFlair
data-flair.training › blogs › fibonacci-series-in-c-using-recursion
Fibonacci Series in C using Recursion - DataFlair
March 9, 2024 - This article will focus on implementing a recursive solution to generate the Fibonacci series in C programming language.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › fibonacci series program in c using recursion
Fibonacci Series in C Using Recursion | Full Code Explained
July 19, 2024 - This hands-on project demonstrates base case setup, recursive calls, and how code unwinds—all fundamental traits of recursive thinking. In this tutorial, you’ll learn how to print Fibonacci series using recursion in C, break down each recursive call, and understand the flow of stack operations.
🌐
Edureka
edureka.co › blog › fibonacci-series-in-c
Fibonacci Series In C | Fibonacci Series Using Recursion | Edureka
March 29, 2022 - In this program we use recursion to generate the fibonacci series. The function fibonacci is called recursively until we get the output. In the function, we first check if the number n is zero or one. If yes, we return the value of n.
🌐
Hero Vired
herovired.com › learning-hub › blogs › fibonacci-series-in-c
Fibonacci Series Program in C Using Recursion
Recursive functions are often used for tasks that require the same operation to be performed multiple times, such as generating a Fibonacci sequence. In a Fibonacci series in C, a recursive function can generate the desired sequence of numbers.
🌐
Dot Net Tutorials
dotnettutorials.net › home › fibonacci series using recursion in c
Fibonacci Series using Recursion in C with Examples - Dot Net Tutorials
November 22, 2021 - Below is the sequence of the Fibonacci Series: In the above diagram, the 0th term is 0, and 1st term is 1 and after it, the next term is obtained by adding the previous two terms. Let’s have a look at the below image to understand it clearly. As we can see in above Image, 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, 2 + 3 = 5, And so on… So, this can be defined mathematically as, So, now let’s write a recursive function for Fibonacci Series based on the above recurrence relation:
🌐
Codeforwin
codeforwin.org › home › c program to find nth fibonacci term using recursion
C program to find nth fibonacci term using recursion - Codeforwin
July 20, 2025 - Logic to find nth fibonacci term using recursion in C programming. Fibonacci series is a series of numbers where the current number is the sum of previous two terms. For Example: 0, 1, 1, 2, 3, 5, 8, 13, 21, ... , (n-1th + n-2th)
🌐
Techcrashcourse
techcrashcourse.com › 2015 › 03 › c-program-fibonacci-series-using-recursion.html
C Program to Print Fibonacci Series using Recursion
We are using a user defined recursive function named 'fibonacci' which takes an integer(N) as input and returns the Nth fibonacci number using recursion as discussed above. The recursion will terminate when number of terms are < 2 because we know the first two terms of fibonacci series are ...
🌐
IncludeHelp
includehelp.com › c-programs › fibonacci-series-recursion.aspx
C program to print fibonacci series using recursion
function funFibonacci(n): if n == 0: return 0 else if n == 1: return 1 else: return funFibonacci(n - 1) + funFibonacci(n - 2) function fibonacciSeries(n): for i from 0 to n-1 do: print(funFibonacci(i)) /*C program to print fibonacii series till N terms.*/ #include <stdio.h> // function to print ...
🌐
Testbook
testbook.com › home › gate › fibonacci series using recursion in c - detailed explanation | testbook.com
Fibonacci Series Using Recursion in C - Detailed Explanation | Testbook.com
In this method, the Fibonacci function is called recursively until the required output is generated. If the number (let's call it m) in the function is either one or zero, the function will return m.
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › program-for-nth-fibonacci-number
Nth Fibonacci Number - GeeksforGeeks
Input: n = 5 Output: 5 Explanation: 5 is the 5th number of Fibonacci series. ... We can use recursion to solve this problem because any Fibonacci number n depends on previous two Fibonacci numbers.
Published   1 month ago