This is a simple 2 statement function that takes n as an argument and returns the nth Fibonacci number. Can be used to display the Fibonacci series upto the integer size limit.
#include <iostream.h> #include <conio.h> unsigned int fibonacci (unsigned int n) { if (n <= 2) { return 1; } else { return fibonacci(n-1) + fibonacci(n-2); } } int main() { unsigned int i, j=0; cout<<"\n Enter the fibonnaci number : "; cin>>i; for(j=1; j<=i; j++) cout<<fibonacci(j)<<" "; getch(); }
my search ended here .
thanksssssssssssssss…….
how recursion prgm excuted …..plzzzz give an instruction…..
Thank you very, very big thanks to you I write it right for me to just start writing programs have had really hard
Nice. Thanks for the article. Also I found this article which discusses two methods to do the same. http://mytechrant.com/?p=50
your programe have very mistakes….
please resolve your mistakes………..