7-p07_rabbit


def get_rabbits(months):
    if months <2 :
        return 1
    return get_rabbits(months-1)+get_rabbits(months-2)

if __name__=='__main__':
    for month in range(1,10+1):
        print(month,'-',get_rabbits(month))
D:\Anaconda\python.exe D:/AI20/06_codes/deeplearning_20/p07_rabbit.py
1 - 1
2 - 2
3 - 3
4 - 5
5 - 8
6 - 13
7 - 21
8 - 34
9 - 55
10 - 89

Process finished with exit code 0

发布了88 篇原创文章 · 获赞 2 · 访问量 1312

猜你喜欢

转载自blog.csdn.net/HJZ11/article/details/104459424