Topic-25: Fibonacci Series using Recursion

Fibonacci:

Fibonacci Series is the pattern of numbers where result is calculated based on the addition of previous two terms .

Code:

#include<stdio.h>

int fib(int n)

{

if(n<=1)

{

return n;

}

return fib(n-1)+fib(n-2);

}

int main()

{

int result;

result=fib(3);

printf(“the result is %d”,result);

return 0;

}

Output:

the result is 2

Leave a Comment

Your email address will not be published. Required fields are marked *