上台阶 代码: import java.util.Scanner; public class sixtyone { public static void main(String[] args) { Scanner reader = new Scanner(System.in); int n=reader.nextInt(); System.out.println(f(n)); } public static int f(int n) { if(n==1) { return 1; } if(n==2) { return 2; } return f(n-1)+f(n-2); } } 运行结果: