题目:{ 1、1、2、3、5、8、13、21、34、…… } 求第30位数字位多少?
在之前蓝桥杯的训练中,学习过用递归算法计算斐波那契数列
数学表达式:F(1)=1,F(2)=1, F(n)=F(n-1)+F(n-2)(n>=2,n∈N*)
C#程序:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Return(30));
}
public static int Return(int i)
{
if (i <= 0)
{
return 0;
}
else if (i == 1)
{
return 1;
}
else
{
return Return(i - 1) + Return(i - 2);
}
}
}
}
















![[在线工具] GitHub项目文件下载加速器](https://notes.tslmeta.com/wp-content/uploads/2021/03/微信截图_20210311100049-1-300x201.png)