
package com.bjsxt.zhp;
/**
* 斐波那契数列
* @author Administrator
* 0 1 1 2 3 5 8 13
*/
public class Test9 {
public static void main(String[] args) {
System.out.println( fn(20));
}
public static int fn(int n){
if(n == 1){
return 0;
}else if(n == 2){
return 1;
}else{
return fn(n-1)+fn(n-2);
}
}
}



初级程序员
by: andyhu2017 发表于:2017-09-01 14:04:50 顶(0) | 踩(0) 回复
好吊呀
回复评论