Hi. I am last year computer science student. I am learning C programming language. I have to generate Fibonacci series using recursion. If you are having the code to perform the same then let me know about it. Thanks in advanced.
Hi. I am last year computer science student. I am learning C programming language. I have to generate Fibonacci series using recursion. If you are having the code to perform the same then let me know about it. Thanks in advanced.
Hi, hope this helps..
I have tried the given code but it didn’t solve my problem. Please try to provide some other solution.Code:#include<stdio.h> #include<conio.h> int fib(int); int f=1,j=0,k=0,i=0,c; void main() { int l; clrscr(); printf("Enter limitn"); scanf("%d",&l); f=0; printf("%dn",f); f=1; printf("%dn",f); for(c=0;c<l;c++) { f=fib(l); printf("%dn",f); } getch(); } int fib(int n) { while(i<n) { if(i<=n) { i++; j=k; k=f; f=k+j; fib(1); return f; } } }
The script that I have mentioned will definitely help you. It is very simple code.
Code:main() { int c=1,f=0,s=1; int i; printf("%d%20dn",f,f); printf("%d%20dn",s,s); for (i=2; i<5||f<s; i++) { c=f+s; f=s; s=c; printf("%d%20dn",i,c); } }
Bookmarks