题解 | #兔子的数量#
兔子的数量
https://www.nowcoder.com/practice/8783056676de4396b0bf816a3561d62f
#!/usr/local/bin/python3 #兔子的数量 def addRt(n): if n == 3: return 5 elif n == 2: return 3 elif n == 1: return 2 else: return addRt(n-1) + addRt(n-2) n = int(input()) print(addRt(n)) 本题主要是使用递归的方式,很简单