当前位置:网站首页>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
边栏推荐
- JMM memory model concept
- 【flask入门系列】Flask-SQLAlchemy的安装与配置
- 【C语言刷LeetCode】1054. 距离相等的条形码(M)
- How to write controller layer code gracefully?
- Teacher wangshuyao's notes on operations research course 08 linear programming and simplex method (simplex method)
- 图像加噪声与矩阵求逆
- Salesforce中过滤器Filter使用的相对日期
- Teacher Wu Enda's machine learning course notes 04 multiple linear regression
- Cesium反射
- Ping principle
猜你喜欢

The core of openresty and cosocket

ECCV 2022丨轻量级模型架ParC-Net 力压苹果MobileViT代码和论文下载

Teacher wangshuyao's notes on operations research course 10 linear programming and simplex method (discussion on detection number and degradation)

基于C语言设计的学生成绩排名系统

游戏资产的革命

Jetpack Compose 中的键盘处理

【冷冻电镜】Relion4.0——subtomogram教程

联邦学习后门攻击总结(2019-2022)

Teacher Wu Enda's machine learning course notes 02 univariate linear regression

【论文阅读 | 冷冻电镜】RELION 4.0 中新的 subtomogram averaging 方法解读
随机推荐
mysql查询区分大小写
实战!聊聊如何解决MySQL深分页问题
模拟卷Leetcode【普通】061. 旋转链表
吴恩达老师机器学习课程笔记 05 Octave教程
【冷冻电镜|论文阅读】子断层平均 M 软件解读:Multi-particle cryo-EM refinement with M
Teacher Wu Enda machine learning course notes 01 introduction
Actual combat! Talk about how to solve the deep paging problem of MySQL
Unity exploration plot access design analysis & process + code specific implementation
吴恩达老师机器学习课程笔记 02 单变量线性回归
分享一些你代码更好的小建议,流畅编码提搞效率
线程 - 线程安全 - 线程优化
【论文阅读】TomoAlign: A novel approach to correcting sample motion and 3D CTF in CryoET
数据库持久化+JDBC数据库连接
Software definition boundary SDP
Leetcode-592: fraction addition and subtraction
【笔记】The art of research - (讲好故事和论点)
吴恩达老师机器学习课程笔记 04 多元线性回归
Teacher wangshuyao's notes on operations research 03 KKT theorem
王树尧老师运筹学课程笔记 09 线性规划与单纯形法(单纯形表的应用)
Teacher wangshuyao's notes on operations research 04 fundamentals of linear algebra