题解 | #N阶楼梯上楼问题#
N阶楼梯上楼问题
https://www.nowcoder.com/practice/c978e3375b404d598f1808e4f89ac551
#include <iostream> using namespace std; int Fibonacci(int n) { if (n == 1 || n == 2) { return n; } else { return Fibonacci(n - 1) + Fibonacci(n - 2); } } int main() { int n; cin >> n; cout << Fibonacci(n) << endl; return 0; }