递归
# 计算小明爬楼梯的爬法数量
def clambstairs1(n):
a = 1
b = 2
c = 4
for i in range(n-3):
c,b,a = a+b+c,c,b
return c
def clambstairs2(n):
fir = {1:1,2:2,3:4}
if n in fir.keys():
return fir[n]
else:
return clambstairs2(n-1)+clambstairs2(n-2)+clambstairs2(n-3)
if __name__ == "__main__":
print(clambstairs2(14))
print(clambstairs1(14))