Saturday, March 17

Fibonacci series using Recursion ~ C program


Here is a C program which prints a Fibonacci series up to a limit using recursion.





#include<stdio.h>


void fibonacci(int a, int b,int count)


{
     printf("%d\t",a+b);
     if(--count) fibonacci(b,a+b,count);
}


void main()
{
     printf("Enter limit:");
     int count;
     scanf("%d", &count);
      printf("0\t 1\t");
     fibonacci(0,1,count-2);
   
     }
    

0 comments :

Post a Comment