n个台阶,一次可以走1步,也可以走2步,有多少种走法,给出具休的走法方案?
def f(n,s=""):
if n <= 0:
print("0" + s)
return
if n == 1:
print("0,1" + s)
return
f(n-1,"," + str(n) + s)
f(n-2,"," + str(n) + s)
def f(n,s=""):
if n <= 0:
print(','.join(s.split(",")[1:]))
return
if n == 1:
print("1" + s)
return
f(n-1,"," + "1" + s)
f(n-2, ","+ "2" + s)