当前位置:网站首页>Function: find the approximate value of the limit of the ratio of the former term to the latter term of Fibonacci sequence. For example, when the error is 0.0001, the function value is 0.618056.
Function: find the approximate value of the limit of the ratio of the former term to the latter term of Fibonacci sequence. For example, when the error is 0.0001, the function value is 0.618056.
2022-07-04 00:40:00 【CTGU-Yoghurt】
subject :
First, explain what Fibonacci sequence is :
( Here I quote a picture written by a friend of mine )

In a nutshell
The first 1 Xiang and di 2 Items for 1, Starting from the back, each item is the sum of the first two items .
A sequence of numbers formed by analogy .
Code details :
#include <stdio.h>
#include "math.h"
float fun()
{
/**********Program**********/
float f1 = 1, f2 = 1,f3=2,t;//
f1 On behalf of the 1 term ,f2 On behalf of the 2 term ,f3 On behalf of the 3 term
while (fabs(f2/f3 - f1/f2) > 0.0001) {
f1 = f2;
t = f2 + f3;
f2 = f3;
f3 = t;
}
return f2/f3;// Method 1
/*float f1 = 1, f2 = 1, f3;
float r1 = 2, r2;
do
{
r2 = r1;
r1 = f1 / f2;
f3 = f1 + f2;
f1 = f2;
f2 = f3;
} while (fabs(r1 - r2) > 1e-4);
return r1;*/// Method 2
/********** End **********/
}
int main()
{
printf("y=%f\n", fun());
}
PS: Happy holidays happy holidays happy holidays happy holidays happy holidays happy holidays happy holidays happy holidays happy holidays happy holidays happy holidays happy holidays happy holidays happy holidays happy holidays happy holidays
边栏推荐
- 国元证券开户是真的安全可靠吗
- Several ways to set up a blog locally [attach relevant software download links]
- (Introduction to database system | Wang Shan) Chapter V database integrity: Exercises
- Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
- 功能:求出菲波那契数列的前一项与后一项之比的极限的 近似值。例如:当误差为0.0001时,函数值为0.618056。
- [cloud native topic -48]:kubesphere cloud Governance - operation - overview of multi tenant concept
- 不得不会的Oracle数据库知识点(一)
- Detailed explanation of the relationship between Zhongtai, wechat and DDD
- 【leetcode】374. Guess the size of the number
- ESP Arduino playing with peripherals (V) basic concept of interrupt and timer interrupt
猜你喜欢

基于.NetCore开发博客项目 StarBlog - (14) 实现主题切换功能

Generic
![[dynamic programming] leetcode 53: maximum subarray sum](/img/f0/80357f9ffc556f3ed4d3aa0901bb1d.jpg)
[dynamic programming] leetcode 53: maximum subarray sum
![[C language] break and continue in switch statement](/img/ae/5967fefcf3262c9d3096e5c7d644fd.jpg)
[C language] break and continue in switch statement

Vscode regular match replace console log(.*)

Self study software testing. To what extent can you go out and find a job?

Recommendation of knowledge base management system

Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
![[NLP] text classification still stays at Bert? Duality is too strong than learning framework](/img/49/1ff6025bdb0445e5638c1451e0b267.jpg)
[NLP] text classification still stays at Bert? Duality is too strong than learning framework
![[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!](/img/28/fc05f2e8d53cf81fd061c799090022.jpg)
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
随机推荐
The FISCO bcos console calls the contract and reports an error does not exist
How to use AHAS to ensure the stability of Web services?
1214 print diamond
Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn
[GNN] hard core! This paper combs the classical graph network model
It is worthy of "Alibaba internal software test interview notes" from beginning to end, all of which are essence
Swagger2 quick start and use
Att & CK actual combat series - red team actual combat - V
Advanced C language - pointer 2 - knowledge points sorting
Understanding of Radix
关于 uintptr_t和intptr_t 类型
我管你什么okr还是kpi,PPT轻松交给你
The difference between objects and objects
P1656 bombing Railway
It's OK to have hands-on 8 - project construction details 3-jenkins' parametric construction
【leetcode】374. Guess the size of the number
Network layer - routing
Global and Chinese markets of distributed control system (DCS) consumption 2022-2028: Research Report on technology, participants, trends, market size and share
Is the account opening of Guoyuan securities really safe and reliable
Regular expression of shell script value