题解 | #Fibonacci#

Fibonacci

https://www.nowcoder.com/practice/17ad6908e36a49f4b06ea96936e8bb25

def cal_num(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return cal_num(n-1)+cal_num(n-2)

num = eval(input())
print(cal_num(num))

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务