Fibonacci Number in C using Recursive Function
Tagged:
A recursive function is a function that calls itself during its execution.
#include<stdio.h>
int fibonacci(unsigned long n){
if(n <=1 )
return n;
else
return fibonacci(n-1) + fibonacci(n-2);
}
int main(){
int n;
printf("enter positive integer: ");
scanf("%i", &n);
int x = fibonacci(n);
printf("fib(%i) = %i", n, x);
return 0;
}
output:
![]()

what r u trying to show.................
the above source code will print the nth number in fibonacci series....
Post new comment