题解 | #兔子的数量#
兔子的数量
https://www.nowcoder.com/practice/8783056676de4396b0bf816a3561d62f
# 定义递归函数
def f(n):
if n==1:
return 2
elif n==2:
return 3
else:
return f(n-1)+f(n-2)
n = int(input())
rabbitNum = f(n)
print(rabbitNum)
def f(n):
if n==1:
return 2
elif n==2:
return 3
else:
return f(n-1)+f(n-2)
n = int(input())
rabbitNum = f(n)
print(rabbitNum)