JAVA
import java.util.*;
//佛波那契数列,从第三个数开始,每个数等于前面两个数之和。
// 1 1 2 3 5 8 13 21 34
//用递归。
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
//多组数据输入就要用while(sc.hasNext())
while(sc.hasNext()){
int month = sc.nextInt();
System.out.println(getAllCount(month));
}
}
public static int getAllCount(int month){
if(month<=0){
return -1;
}
//当月份小于3
if(month<3){
return 1;
}else{
//从三月开始为上个月和上上个月之和
return getAllCount(month -1) + getAllCount(month -2);
}
}
}


京公网安备 11010502036488号