C PROGRAMMINGDATA STRUCTURES

write a c program print fibonacci series using recursion

Fibonacci series using recursion?


#include
int fib(int n)
{
if (n <= 1)
return n;
else
return fib(n-1) + fib(n-2);
}
main()
{
int n,i;
printf("Enter the number of elements: n");
scanf("%d",&n);
printf("Fibonacci Series: n");
for(i=0;i<n;i++)
printf("%d ", fib(i));
}
Show More

Related Articles

Leave a Reply

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

Back to top button