当前位置:网站首页>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
边栏推荐
- Is it really possible that the monthly salary is 3K and the monthly salary is 15K?
- Arc 135 supplementary report
- Five high-frequency questions were selected from the 200 questions raised by 3000 test engineers
- P1656 bombing Railway
- 不得不会的Oracle数据库知识点(三)
- [CSDN Q & A] experience and suggestions
- Bodong medical sprint Hong Kong stocks: a 9-month loss of 200million Hillhouse and Philips are shareholders
- P1339 [USACO09OCT]Heat Wave G
- Struct in linked list
- It's OK to have hands-on 8 - project construction details 3-jenkins' parametric construction
猜你喜欢
What is the potential of pocket network, which is favored by well-known investors?
Similarities and differences of text similarity between Jaccard and cosine
Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Network layer - routing
Weekly open source project recommendation plan
功能:将主函数中输入的字符串反序存放。例如:输入字符串“abcdefg”,则应输出“gfedcba”。
打印菱形图案
Qtcharts notes (V) scatter diagram qscatterseries
STM32 key light
随机推荐
ESP Arduino playing with peripherals (V) basic concept of interrupt and timer interrupt
NLP Chinese corpus project: large scale Chinese natural language processing corpus
不得不会的Oracle数据库知识点(三)
[dynamic programming] leetcode 53: maximum subarray sum
MySQL is installed as a Windows Service
Global and Chinese markets for coronary artery disease treatment devices 2022-2028: Research Report on technology, participants, trends, market size and share
A-Frame虚拟现实开发入门
Gauss elimination method and template code
ITK learning notes (VII) the position of ITK rotation direction remains unchanged
【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
Development and application of fcitx functional plug-ins
What is the GPM scheduler for go?
The upload experience version of uniapp wechat applet enters the blank page for the first time, and the page data can be seen only after it is refreshed again
A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders
ISBN number
网上的低佣金链接安全吗?招商证券怎么开户?
It is worthy of "Alibaba internal software test interview notes" from beginning to end, all of which are essence
Suggestions for improving code quality
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
Global and Chinese markets for blood and liquid heating devices 2022-2028: Research Report on technology, participants, trends, market size and share