C++ | Fibonacci Series - Recursion
January 22, 2009 | Posted in Programming, Source Codes and Algorithms |
Note: Disregard the functions it is named after me. But the good thing is that it works.
#include <stdlib.h>
#include <conio.h>
#include <iostream>
using namespace std;
int abz(int n);
main()
{
int a;
cout << "Enter any integer above 0 to find its fibonacci value:";
cin >> a;
cout << abz(a);
cout << "\n";
getch();
}
int abz(int n)
{
if ( n == 0)
{
return 0;
}
else if ( n == 1 )
{
return 1;
}
else
return abz( n -1) + abz(n-2);
}
Posted by: abzkei