小红上楼梯有2种方式,一次1步,或一次3步,现在有20个台阶,问有多少种方案?要求用递归和非递归两种方法解决
# 非递归方式 for i in range(0,21): # oneStep for j in range(1,7): #threeStep if i*1+j*3 == 20: print("oneStep=" + str(i) + ", threeStep=" + str(j))