package com.Summer_0419.cn;
/**
* @author Summer
* 一列數的規則如下: 1、1、2、3、5、8、13、21、34 .....
* 求第30位數是多少?
* 使用遞歸實作
*
*/
public class Test_Method08 {
public static void main(String[] args) {
int num = count(30);
System.out.println(num);
}
private static int count(int weishu) {
if (weishu==1||weishu==2) {
return 1;
}
return count(weishu-1)+count(weishu-2);
}
}
轉載于:https://www.cnblogs.com/summerdata/p/10739129.html