当前位置:网站首页>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
边栏推荐
- 功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
- The difference between objects and objects
- Global and Chinese market of glossometer 2022-2028: Research Report on technology, participants, trends, market size and share
- P3371 [template] single source shortest path (weakened version)
- Suggestions for improving code quality
- For loop
- 2-Redis架构设计到使用场景-四种部署运行模式(下)
- [software testing] you haven't mastered these real interview questions of big companies?
- Struct in linked list
- Global and Chinese market of process beer equipment 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
我管你什么okr还是kpi,PPT轻松交给你
Sequence list and linked list
MPLS experiment
(Introduction to database system | Wang Shan) Chapter V database integrity: Exercises
How to be a professional software testing engineer? Listen to the byte five year old test
From functional testing to automated testing, how did I successfully transform my salary to 15K +?
Yyds dry goods inventory three JS source code interpretation - getobjectbyproperty method
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
MySQL winter vacation self-study 2022 12 (1)
P3371 [template] single source shortest path (weakened version)
随机推荐
MySQL 8.0.12 error: error 2013 (HY000): lost connection to MySQL server during query
功能:将主函数中输入的字符串反序存放。例如:输入字符串“abcdefg”,则应输出“gfedcba”。
Generic
A method to solve Bert long text matching
不得不会的Oracle数据库知识点(三)
7.1 学习内容
Development and application of fcitx functional plug-ins
数据库表外键的设计
[about text classification trick] things you don't know
功能:求出菲波那契数列的前一项与后一项之比的极限的 近似值。例如:当误差为0.0001时,函数值为0.618056。
UTS | causal reasoning random intervention based on Reinforcement Learning
2020.2.14
Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
MySQL winter vacation self-study 2022 12 (2)
P1629 postman delivering letter
[GNN] hard core! This paper combs the classical graph network model
Similarities and differences of text similarity between Jaccard and cosine
Att & CK actual combat series - red team actual combat - V
What is the GPM scheduler for go?
Suggestions for improving code quality