Tabsofficial 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

Comments »

The URI to TrackBack this entry is: http://quesera.blogsome.com/2009/01/22/c-fibonacci-series/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment



Anti-spam measure: please retype the above text into the box provided.