1 package FushiExam;
2 import java.util.*;
3 public class Text_1 {
4
5 public static void main(String[] args) {
6 /*
7 * 有一对兔子,从出生后第3个月起,每个月都生一对兔子,小兔子长到第三个月后
8 * 每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数是?
9 * 也就是找前n个数:1 1 2 3 5 8 13...的规律
10 */
11 //菲波拉契数列问题
12 Scanner scan=new Scanner(System.in);
13 System.out.println("输入数:");
14 int n=scan.nextInt();
15 int first=1,second=1,next;
16 System.out.println(first);
17 System.out.println(second);
18 for(int i=3;i<=n;i++) {
19 next=first+second;
20 System.out.println(next);
21 first=second;
22 second=next;
23 }
24
25
26 }
27
28 }