用控制台写的计算斐波那契数列
新建一个类
namespace 斐波那契数列
{
class student
{
public int shy(int index)
{
if (index<1)
{
return 0;
}
else if(index==1||index==2)
{
return 1;
}
else
{
return shy(index - 1) + shy(index-2);
}
}
}
}
主窗体
namespace 斐波那契数列
{
class Program
{
static void Main(string[] args)
{
student stu = new student();
Console.WriteLine(stu.shy(80));
Console.ReadLine();
}
}
}
来源:CSDN
作者:Zombie°
链接:https://blog.csdn.net/weixin_45755086/article/details/103783633