当前位置:网站首页>Exercise 10-6 recursively find Fabonacci sequence
Exercise 10-6 recursively find Fabonacci sequence
2022-07-03 14:09:00 【ᯤ⁹ᴳ⁺ ·】
exercises 10-6 Recursive search Fabonacci The sequence (10 branch )
This problem requires the realization of Fabonacci A function of a sequence item .Fabonacci The definition of sequence is as follows :
f(n)=f(n−2)+f(n−1) (n≥2), among f(0)=0,f(1)=1.
Function interface definition :
int f( int n );
function f Should return to section n individual Fabonacci Count . The title guarantees that the input and output are in the long integer range . It is suggested to use recursion to realize .
Sample referee test procedure :
#include <stdio.h>
int f( int n );
int main()
{
int n;
scanf("%d", &n);
printf("%d\n", f(n));
return 0;
}
/* Your code will be embedded here */
sample input :
6
sample output :
8int f( int n ){
int number;
if(n==0){
number=0;
}else if(n==1){
number=1;
}else{
number=f(n-1)+f(n-2);
}
return number;
}
边栏推荐
- Function calling convention
- js . Find the first palindrome string in the array
- Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
- Redis:Redis的数据结构、key的操作命令
- Interface for querying IP home
- QT learning 17 dialog box and its types
- Analysis of the characteristics of page owner
- 核酸修饰的金属有机框架药物载体|PCN-223金属有机骨架包载Ad金刚烷|ZIF-8包裹阿霉素(DOX)
- [combinatorics] permutation and combination (two counting principles, examples of set permutation | examples of set permutation and circle permutation)
- Uniapp skills - scrolling components -1
猜你喜欢

小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。

Redis: commandes d'action pour les données de type chaîne

Current situation, analysis and prediction of information and innovation industry

Redis:Redis的数据结构、key的操作命令

“又土又穷”的草根高校,凭什么被称为“东北小清华”?

Qt学习21 Qt 中的标准对话框(下)

可编程逻辑器件软件测试

QT learning 22 layout manager (I)
[email protected])"/>金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])

FPGA测试方法以Mentor工具为例
随机推荐
Qt学习20 Qt 中的标准对话框(中)
How to use lxml to judge whether the website announcement is updated
Qt学习19 Qt 中的标准对话框(上)
Comprehensive case of MySQL data addition, deletion, modification and query
1px problem of mobile terminal
玖逸云黑免费无加密版本源码
JVM垃圾回收机
Fabric. JS document
Go 1.16.4: purpose of go mod tidy
JS get DPI, PX to cm, cm to PX
Message subscription and publishing
Implementation of Muduo asynchronous logging
如何使用lxml判断网站公告是否更新
Qt学习18 登录对话框实例分析
Use and design of Muduo buffer class
JS first summary
从零开始的基于百度大脑EasyData的多人协同数据标注
八大排序
QT learning 20 standard dialog box in QT (middle)
Canvas utility library fabric JS user manual