星空网 > 软件开发 > ASP.net

C#递归题目代码

一列数的规则如下: 1、1、2、3、5、8、13、21、34...... 求第30位数是多少, 用递归算法实现。

代码:

public class MainClass{public static void Main(){Console.WriteLine(Foo(30));}public static int Foo(int i){if (i <= 0)return 0;else if(i > 0 && i <= 2)return 1;else return Foo(i -1) + Foo(i - 2);}}

  




原标题:C#递归题目代码

关键词:C#

C#
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

JudoLaunch:https://www.goluckyvip.com/tag/21777.html
Judy:https://www.goluckyvip.com/tag/21778.html
Judy话跨境:https://www.goluckyvip.com/tag/21779.html
跨境邮件推广:https://www.goluckyvip.com/tag/2178.html
Julep:https://www.goluckyvip.com/tag/21780.html
Juliusworks:https://www.goluckyvip.com/tag/21781.html
别犹豫了,品牌种草营销就是现在!:https://www.kjdsnews.com/a/1836479.html
安能物流的2024:变革不能停:https://www.kjdsnews.com/a/1836480.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流