当前位置:网站首页>Hj37 statistics of the total number of rabbits per month Fibonacci series
Hj37 statistics of the total number of rabbits per month Fibonacci series
2022-07-29 07:00:00 【fK0pS】
HJ37 Count the total number of rabbits every month Fibonacci sequence
There is a kind of rabbit , From the day after birth 3 A rabbit has been born every month since last month , The little rabbit grows to the third month and gives birth to another rabbit every month .
Example : Suppose a rabbit 3 Months was born , So it's the first 5 A rabbit will be born every month from the beginning of next month .
There was a rabbit in January , If the rabbits don't die , Ask No n What's the total number of rabbits in a month ?
Data range : Input satisfaction 1 \le n \le 31 \1≤n≤31
Input description :
Enter a int An integer of type denotes the th n Months
Output description :
Output the corresponding total number of Rabbits
ip = input()
def df(n):
if n < 3: return 1
return df(n-1) + df(n-2)
print(df(ip))
This question is very interesting :
The number of rabbits per month = The number of rabbits last month ( Because rabbits don't die , So last month's rabbit , The current month is still alive ) + The new born rabbit in the current month ( The first born rabbit of the current month , The number of rabbits in the first two months , Because the rabbits in the first two months are adult rabbits , All have fertility ) = df(n-1) +df(n-2)
A typical Fibonacci sequence
边栏推荐
- Analysis of four isolation levels of MySQL things
- SDN topology discovery principle
- Teacher Wu Enda machine learning course notes 05 octave tutorial
- Teacher wangshuyao's operations research course notes 07 linear programming and simplex method (standard form, base, base solution, base feasible solution, feasible base)
- 【冷冻电镜入门】加州理工公开课课程笔记 Part 3: Image Formation
- Teacher wangshuyao's notes on operations research 05 linear programming and simplex method (concept, modeling, standard type)
- 【冷冻电镜|论文阅读】emClarity:用于高分辨率冷冻电子断层扫描和子断层平均的软件
- 'function VTable for error: undefined reference to... 'cause and solution of the problem
- Teacher Wu Enda's machine learning course notes 03 review of linear algebra
- Unity免费元素特效推荐
猜你喜欢

游戏资产的革命

王树尧老师运筹学课程笔记 10 线性规划与单纯形法(关于检测数与退化的讨论)

基于C语言设计的学籍管理系统

2D cartoon rendering - advanced skills

Federal learning backdoor attack summary (2019-2022)

剑指 Offer II 115:重建序列

Unity免费元素特效推荐

N2 interface of 5g control plane protocol

【论文阅读 | cryoET】Gum-Net:快速准确的3D Subtomo图像对齐和平均的无监督几何匹配

Teacher Wu Enda's machine learning course notes 02 univariate linear regression
随机推荐
模拟卷Leetcode【普通】081. 搜索旋转排序数组 II
IDEA中实现Mapper接口到映射文件xml的跳转
Teacher wangshuyao's notes on operations research course 10 linear programming and simplex method (discussion on detection number and degradation)
2D cartoon rendering - advanced skills
Can MySQL export tables regularly?
线程 - 线程安全 - 线程优化
[CF1054H] Epic Convolution——数论,卷积,任意模数NTT
【讲座笔记】如何在稀烂的数据中做深度学习?
Salesforce中过滤器Filter使用的相对日期
2022年SQL经典面试题总结(带解析)
【干货备忘】50种Matplotlib科研论文绘图合集,含代码实现
Thread synchronization - producers and consumers, tortoise and rabbit race, dual thread printing
Share some tips for better code, smooth coding and improve efficiency
Mutual conversion between Base64 and file
The latest pycharm2018 cracking tutorial
Federal learning backdoor attack summary (2019-2022)
基于C语言设计的学生成绩排名系统
模拟卷Leetcode【普通】172. 阶乘后的零
vscode通过remotessh结合xdebug远程调试php解决方案
网上传说软件测试培训真的那么黑心吗?都是骗局?