码迷,mamicode.com
首页 > 编程语言 > 详细

【Java】 Thinking in Java 4.8 练习9

时间:2014-07-25 02:41:24      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:style   blog   java   color   for   re   c   div   

 1 /**
 2  * 题目:创建一个方法,接受一个整数参数,并显示从第一个元素开始总共由该参数指定的个体数所构成的所有斐波那契数字。
 3  * 例如:运行Fibonacci5,得到,1,1,2,3,5.
 4  * @author Administrator
 5  *
 6  */
 7 public class Fibonacci {
 8 
 9     public static void main(String[] args) {
10         int i = 1;
11         int j = 1;
12         int k = 0;
13         int counter = 2;
14         for (; true;) {
15             k = i + j;
16             counter++;
17             System.out.println(k);
18             if (counter == 10) {
19                 return;
20             }
21 
22             i = j;
23             j = k;
24         }
25 
26     }
27 }

【Java】 Thinking in Java 4.8 练习9,布布扣,bubuko.com

【Java】 Thinking in Java 4.8 练习9

标签:style   blog   java   color   for   re   c   div   

原文地址:http://www.cnblogs.com/outOfview/p/3866739.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!