来自:算法爱好者
有一座高度是10级台阶的楼梯,从下往上走,每跨一步只能向上1级或者2级台阶,要求用程序来求出一共有多少种走法?
f(10) = f(9) + f(8) f(9) = f(8) + f(7) f(8)= f(7)+ f(6)
.....................................................................
.....................................................................
....................................................................
f(n) = f(n-1) + f(n-2) (n>=3) f(1) = 1 f(2) = 2