斐波那契数列

原创
2014/03/26 10:27
阅读数 133

package com.program;

public class Rabbits { public static void main(String[] args) {// a(n)=a(n-1)+a(n-2) (n>=3) System.out.println(1 + " " + "1"); System.out.println(2 + " " + "2"); int f1 = 1, f2 = 1, f, m = 24; for (int i = 3; i <= m; i++) { f = f2; f2 = f1 + f2; f1 = f; System.out.println(+i + " " + f2); } }

}

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部