C#递归复习
程序员文章站
2022-07-02 17:00:30
static void Main(string[] args) { Console.WriteLine("请输入你要的数字:"); long flag = Convert.ToInt64(Console.ReadLine()); long result = MakeRusult(flag); Con ......
static void main(string[] args)
{
console.writeline("请输入你要的数字:");
long flag = convert.toint64(console.readline());
long result = makerusult(flag);
console.writeline("结果是:{0}", convert.tostring(result));
console.readkey();
}
static long makerusult(long number)
{
if (number == 1 || number == 2)
{
return 1;
}
else
{
return makerusult(number - 1) + makerusult(number - 2);
}
}