当前位置:网站首页>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
边栏推荐
- Simulation volume leetcode [ordinary] 172. Zero after factorial
- IO stream - file - properties
- 王树尧老师运筹学课程笔记 05 线性规划与单纯形法(概念、建模、标准型)
- 【笔记】The art of research(明白问题的重要性)
- Simulation volume leetcode [general] 150. evaluation of inverse Polish expression
- Teacher Wu Enda machine learning course notes 05 octave tutorial
- vscode通过remotessh结合xdebug远程调试php解决方案
- Teacher wangshuyao's operations research course notes 07 linear programming and simplex method (standard form, base, base solution, base feasible solution, feasible base)
- Jetpack Compose 中的键盘处理
- 新同事写了几段小代码,把系统给搞崩了,被老板爆怼一顿!
猜你喜欢
联邦学习后门攻击总结(2019-2022)
Federal learning backdoor attack summary (2019-2022)
Actual combat! Talk about how to solve the deep paging problem of MySQL
Is online legend software testing training really so black hearted? Are they all scams?
vim文本编辑器的一些使用小技巧
N2 interface of 5g control plane protocol
IO stream - file - properties
Share some tips for better code, smooth coding and improve efficiency
【CryoEM】FSC, Fourier Shell Correlation简介
Unity free element special effect recommendation
随机推荐
【冷冻电镜】RELION4.0之subtomogram对位功能源码分析(自用)
Simulation volume leetcode [normal] 061. rotating linked list
阿里一面,给了几条SQL,问需要执行几次树搜索操作?
王树尧老师运筹学课程笔记 08 线性规划与单纯形法(单纯形法)
模拟卷Leetcode【普通】061. 旋转链表
Cesium reflection
王树尧老师运筹学课程笔记 01 导学与绪论
'function VTable for error: undefined reference to... 'cause and solution of the problem
DM数据守护集群搭建
2D cartoon rendering - advanced skills
Ping principle
CVPR2022Oral专题系列(一):低光增强
王树尧老师运筹学课程笔记 02 高等数学基础
【论文阅读 | cryoET】Gum-Net:快速准确的3D Subtomo图像对齐和平均的无监督几何匹配
5g service interface and reference point
Summary of 2022 SQL classic interview questions (with analysis)
【技能积累】写邮件时的常用表达
【冷冻电镜】Relion4.0——subtomogram教程
王树尧老师运筹学课程笔记 10 线性规划与单纯形法(关于检测数与退化的讨论)
基于C语言实现图书借阅管理系统