Thursday, 24 January 2013

fibonacci series

#include <iostream>

using namespace std;
int fibonacci(int);
int main()
{

    for(int number=0; number<=10; number++)

    cout << fibonacci(number)<< " ";
    return 0;
}

int fibonacci(int number)
{

    if(number<=1)
    {


       return number;
    }

    else
    return fibonacci(number-1) + fibonacci(number-2);

}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Enterprise Project Management