首页 > 代码库 > 递归练习之斐波那契数列

递归练习之斐波那契数列

/*********************************************************************************  
 Copyright (C), 1988-1999, drvivermonkey. Co., Ltd.  
 File name:   
 Author: Driver Monkey  
 Version:   
 Mail:bookworepeng@hotmail.com  qq:196568501
 Date: 2014.04.02  
 Description:   递归练习之阶乘运算
 *********************************************************************************/  

#include <iostream>
#include <sstream>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <memory.h>
#include <thread> 
#include <stdlib.h>     /* labs */
#include <math.h>

using namespace std;

static double factorial(int x);

int main()
{
    cout<<"square_root = " <<fbi(10)<<endl;

    while(1);
    return 0;
}



static double fbi(int x)
{
    int y = 0;
    
    if(x == 0)
    {
        return 0;
    }else if(x = 1)
    {
        return 1;
    }else
    {
       int temp = fbi(x - 1)+ fbi(x - 2);
       cout<<"n = "<<x<<endl; cout<<"y = "<<temp<<endl;
       return temp;
    }
}

递归练习之斐波那契数列