1,1,2,3,5,8,13,21,34,55....
class Program
{
static void Main(string[] args)
{
//找规律:
//1,1,2,3,5,8,13,21,34,55,......
int num = 30;
Console.WriteLine(GetNum(30));
Console.ReadKey();
}
/// <summary>
/// 求第30位数的值
/// </summary>
/// <param name="i"></param>
/// <returns></returns>
private static int GetNum(int i)
{
if (i<=0)
{
return 0;
}else if (i>0 && i<=2)
{
return 1;
}
else
{
return GetNum(i - 1) + GetNum(i - 2);
}
}
}