当前位置:网站首页>剑指Offer | 斐波那契数列
剑指Offer | 斐波那契数列
2022-06-28 09:16:00 【小雅痞】
使用递归或者循环。
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;
}
边栏推荐
- 手机买同业存单基金开户选哪家证券公司比较好,比较安全呢
- 小程序 :遍历list里面的某个数组的值,等同于 for=“list” list.comment里面的某一项
- 1182:合影效果
- Which securities company is better and safer to choose when opening an account for the inter-bank certificate of deposit fund with mobile phone
- Is it safe to open an account for mobile phone stock speculation?
- Illustration of MySQL binlog, redo log and undo log
- What is online account opening? Is it safe to open an account online now?
- 两道面试小Demo
- How do I open an account on my mobile phone? Is it safe to open an account online now?
- Data modeling based on wide table
猜你喜欢

虚拟机14安装win7(图教程)

SQL注入之文件读写

使用transform:scale之后导致页面鼠标悬浮事件消失

Learn how Alibaba manages the data indicator system

買賣股票費用計算

Automatic conversion - interview questions
![[ybtoj advanced training guidance] class roll call [string hash]](/img/5b/bbf8fa51d180b50fbbee4bcc278c70.jpg)
[ybtoj advanced training guidance] class roll call [string hash]

APICloud携手三六零天御,助力企业守好App安全“第一关”

It only takes two steps to find the right PMP organization, one check and two questions

Expérience d'optimisation SQL: de 30248 secondes à 0001 secondes
随机推荐
为什么SELECT * 会导致查询效率低?
Summary of PMP learning experience
Fire fighting work and measures in Higher Vocational Colleges
图解MySQL的binlog、redo log和undo log
Fire safety hazards
[share OpenGL tutorial]
Expérience d'optimisation SQL: de 30248 secondes à 0001 secondes
Implementation of single sign on
Discussion on safety management of centralized maintenance construction site of substation under the mode of operation and maintenance
Deployment of MySQL database in Linux Environment
spark的资源调度和任务调度
两道面试小Demo
Why does select * lead to low query efficiency?
Common tools for interface testing --postman
Learn how Alibaba manages the data indicator system
虛擬機14安裝win7(圖教程)
Copy & Deepcopy
Find the total number of 1 appearing in the integer 1-N and the number of 1 in the binary of the integer
Discussion on the practice of fire emergency lighting system in the field of building electrical design
01-分布式系统概述