/** * 斐波那契数列 * @author Administrator * 0 1 1 2 3 5 8 13 */ public class Test2 { 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: 发表于:2017-06-23 17:37:55 顶(0) | 踩(0) 回复
??
回复评论