C Program to Find Fibonacci Series using Recursion

C Program to Find Fibonacci Series using Recursion

Write a Program to Find Fibonacci Series using Recursion

// C Program to Find Fibonacci Series using Recursion

#include <stdio.h>

int fibonnaci(int n)
{
	if(n == 0)
        return n;
	if(n == 1)
        return n;

	return fibonnaci(n - 1) + fibonnaci(n - 2);
}

int main()
{
	int n;
	printf("Enter Number :--> ");
	scanf("%d", &n);

	printf("Fibonacci Series :--> ");
	for(int i=0; i<n; i++)
    {
        int result = fibonnaci(i);
        printf("%d  ", result);
    }
        return 0;
}

Output:

Enter Number :--> 8
Fibonacci Series :--> 0  1  1  2  3  5  8  13