题解 | #兔子的数量#
兔子的数量
https://www.nowcoder.com/practice/8783056676de4396b0bf816a3561d62f
def count(n): if n==1:#解决初始值 return 2 if n ==2:#解决初始值 return 3 return count(n-1) + count(n-2)#返回n大于2时的值 n = int(input()) c = count(n) print(c)
兔子的数量
https://www.nowcoder.com/practice/8783056676de4396b0bf816a3561d62f
def count(n): if n==1:#解决初始值 return 2 if n ==2:#解决初始值 return 3 return count(n-1) + count(n-2)#返回n大于2时的值 n = int(input()) c = count(n) print(c)
相关推荐