public int GetNumberAtPos(int pos)
{
if (pos == 0 || pos == -1)
{
return 0;
}
if (pos == 1)
{
return 1;
}
int res = GetNumberAtPos(pos - 1) + GetNumberAtPos(pos - 2);
return res;
}
算法:【一列数的规则如下: 1、1、2、3、5、8、13、21、34 ,求第30位数是多少, 用递归算法实现。(C#语言)】
最新推荐文章于 2022-02-16 07:27:46 发布