如果兔子在出生两个月后,就有了繁殖能力,一堆兔子每个月能生出一对小兔子来。假设所有的兔子都不死,那么一年后可以繁殖多少个小兔子?
兔子对数:1 ,1,2,3,5,8,13,21,34,55,89,144
递归方式
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Fbi
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine(Fbi(i));
}
Console.ReadKey();
}
public static int Fbi(int i)
{
if (i < 2)
{
return i == 0 ? 0 : 1;
}
return Fbi(i - 1) + Fbi(i - 2);
}
}
}