public class Rabbit {
public static void main(String[] args) {
// System.out.println(getRabbits(16));
getRabbits2(10,4);
}
//斐波那契兔子,获取某个月的兔子数目[从一对小兔子开始]
public static long getRabbits(int month){
long a=1,b=1;
for(int i=0;i<month;){
if(month==1||month==2)return 1;
if(i==month-1)return a;
a+=b; i++;
if(i==month-1)return b;
b+=a; i++;
}
return b;
}
public static long getRabbits2(){
int a=1,b=1;
for(int i=0;i<5;i++){
System.out.println(a+":"+b);
a+=b;
b+=a;
}
return 0;
}
}
public static void main(String[] args) {
// System.out.println(getRabbits(16));
getRabbits2(10,4);
}
//斐波那契兔子,获取某个月的兔子数目[从一对小兔子开始]
public static long getRabbits(int month){
long a=1,b=1;
for(int i=0;i<month;){
if(month==1||month==2)return 1;
if(i==month-1)return a;
a+=b; i++;
if(i==month-1)return b;
b+=a; i++;
}
return b;
}
public static long getRabbits2(){
int a=1,b=1;
for(int i=0;i<5;i++){
System.out.println(a+":"+b);
a+=b;
b+=a;
}
return 0;
}
}