Recursive Fibonacci

前端 未结 13 1686
情歌与酒
情歌与酒 2020-12-07 18:52

I\'m having a hard time understanding why

#include 

using namespace std;

int fib(int x) {
    if (x == 1) {
        return 1;
    } else {
         


        
13条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 19:24

    int fib(int x) 
    {
        if (x < 2)
          return x;
        else 
          return (fib(x - 1) + fib(x - 2));
    }
    

提交回复
热议问题