a program to print n terms of Fibonacci series using recursion.
the problem is that when am executing the code the loop is not stopping where it should...
Code:
#include<stdio.h>
#include<conio.h>
void recurring_fibonaucci(int ,long int ,long int );
int main()
{
int len;
printf("\t\t\tFibonaucci series\n\nlength of the series should be between 1 to 47.");
do {
printf("\nenter the length of series :");
scanf("%d",&len);
printf("\n");
}while(!(len>1&&len<47));//length should be between 1 and 47
printf("\n\ngenerated number(s) via Recurion\n");
long int r_m=0,r_n=1;
printf("%ld\t",r_m);
recurring_fibonaucci(len ,r_m ,r_n);
getch();
return 0;
}
void recurring_fibonaucci(int len,long int r_m,long int r_n) {
// printf("\nlength: %d\n\n",len);
while(len>1) {
printf("%ld\t",r_n);
len=len-1;
recurring_fibonaucci(len ,r_n ,r_m+r_n);
}
}