题解 | #统计每个月兔子的总数#
统计每个月兔子的总数
http://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395
import java.util.Scanner;
public class Main{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
while(in.hasNext()){
int month = in.nextInt();
int sum=getAll(month);
System.out.println(sum);
}
}
public static int getAll(int m){
if(m==1 || m==2){
return 1;
}else{
return getAll(m-1)+getAll(m-2);
}
}
}