当前位置:网站首页>Sword finger offer | Fibonacci sequence
Sword finger offer | Fibonacci sequence
2022-06-28 09:35:00 【Minor Yapi】
Use recursion or loops .
1 1 2 3 5 …
public int Fibonacci(int n) {
if(n<=1){
return n;
}
//return Fibonacci(n-1)+Fibonacci(n-2);
int a=0,b=1;
while(--n>0){
int flag = a;
a = b;
b = flag+b;
}
return b;
}
边栏推荐
- Bron filter Course Research Report
- June 27, 2022: give a 01 string with a length of N. now please find two intervals so that the number of 1 is equal and the number of 0 is equal in the two intervals. The two intervals can intersect bu
- spark的资源调度和任务调度
- Which occupational groups are suitable for the examination
- HDI blind hole design, have you noticed this detail?
- 数据挖掘建模实战
- Inventory of excellent note taking software: good-looking and powerful visual note taking software, knowledge map tools heptabase, hydrogen map, walling, reflect, infranodus, tiddlywiki
- File operations in QT
- HDI的盲孔设计,你注意到这个细节了吗?
- Ingersoll Rand面板维修IR英格索兰微电脑控制器维修XE-145M
猜你喜欢
1180:分数线划定/P1068 [NOIP2009 普及组] 分数线划定
Apache Doris 成为 Apache 顶级项目
Stock suspension
JVM family (2) - garbage collection
小米旗下支付公司被罚 12 万,涉违规开立支付账户等:雷军为法定代表人,产品包括 MIUI 钱包 App
Data visualization makes correlation analysis easier to use
Learn how Alibaba manages the data indicator system
图解MySQL的binlog、redo log和undo log
1182:合影效果
DBeaver安装与使用教程(超详细安装与使用教程)
随机推荐
Which occupational groups are suitable for the examination
数据挖掘建模实战
Threads and processes
Key summary IV of PMP examination - planning process group (2)
redis5.0的槽点迁移,随意玩(单机迁移集群)
[ybtoj advanced training guidance] class roll call [string hash]
Check whether the table contains rows SQL Server 2005 - check whether a table contains rows or not SQL Server 2005
RESTful风格
JVM系列(2)——垃圾回收
当面试官让你用两种方式写BinarySort
Decision table method for basic content learning of software testing (2)
P2394 yyy loves Chemistry I
Expérience d'optimisation SQL: de 30248 secondes à 0001 secondes
SQL 優化經曆:從 30248秒到 0.001秒的經曆
手机号、邮箱正则验证[通俗易懂]
==和eqauls()的区别
异常处理4种方法
Importerror: no module named image [duplicate] - importerror: no module named image [duplicate]
全链路业务追踪落地实践方案
Scenario method and error recommendation method for learning basic content of software testing (2)