1.有一对兔子,从出生后第三个月起每个月都生一对兔子,小兔子涨到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月兔子总数为多少?

程序分析:斐波那契数列 0.1.1.2.3.5.8.13.21

    /**
     * 斐波那契数列
     * @param months
     * @return
     */
    public static int fib(int months) {
        if(months==0){
            return 0;
        }else if(months==1){
            return 1;
        }else{
            return fib(months - 1) + fib(months - 2);
        }
    }
View Code

相关文章:

  • 2022-12-23
  • 2022-01-10
  • 2021-10-10
  • 2021-11-28
  • 2021-05-25
  • 2021-11-01
猜你喜欢
  • 2021-05-23
  • 2021-12-29
  • 2022-01-10
  • 2021-10-09
  • 2021-08-26
  • 2021-08-23
相关资源
相似解决方案