当前位置:网站首页>Calculate the sum of sequences
Calculate the sum of sequences
2022-07-02 11:04:00 【Beauty of algorithm and programming】
Problem description
There's a sequence of scores :2/1,3/2,5/3,8/5,13/8,21/13... Find the front of this sequence 20 Sum of items .
Example :
Input : Enter the first twenty , And take two decimal places .
Output :32.66
2. Algorithm description
Given two starting numbers , Assign values respectively , Then put it into the loop , According to the law , The numerator is the last group of numerators and the denominator , Concurrent recurrence , Until item 20 , Finally, sum , The results of .
3. Experimental discussion and results
Find out the rules , And write a cycle according to the law , Then write the program .
| a=1 b=2 s=0 for I in range(1,21): s+=b/a a , b=b , b +a print(s) print('=%.2f'%s) |
Four . Conclusion
The main consideration of this problem is to find out the rules of numerator and denominator , And put it into the loop , Calculate and get the result .
边栏推荐
- 华为应用市场应用统计数据问题大揭秘
- [quick application] win7 system cannot run and debug projects using Huawei ide
- Matlab processing of distance measurement of experimental electron microscope
- Creation and use of unified links in Huawei applinking
- PCL 投影点云
- 华为联机对战服务玩家掉线重连案例总结
- The most detailed MySQL installation tutorial
- [ark UI] implementation of the startup page of harmonios ETS
- Easyexcel, a concise, fast and memory saving excel processing tool
- [AGC] build service 3 - authentication service example
猜你喜欢
![[applinking practical case] share in app pictures through applinking](/img/12/5616f1fa55387b81e25e55a98022b9.png)
[applinking practical case] share in app pictures through applinking

Use of vscode tool

Use Huawei performance management service to configure the sampling rate on demand
![[play with FPGA learning 4 in simple terms ----- talk about state machine design]](/img/e0/95f8b8c5116c57455e54ad12372f12.png)
[play with FPGA learning 4 in simple terms ----- talk about state machine design]

二叉树专题--AcWing 18. 重建二叉树(利用前、中序遍历,构建二叉树)

Special topic of binary tree -- acwing 1497 Traversal of the tree (use post and mid order traversal to build a binary tree)
![二叉树专题--洛谷 P3884 [JLOI2009]二叉树问题(dfs求二叉树深度 bfs求二叉树宽度 dijkstra求最短路)](/img/c2/bb85b681af0f78b380b1d179c7ea49.png)
二叉树专题--洛谷 P3884 [JLOI2009]二叉树问题(dfs求二叉树深度 bfs求二叉树宽度 dijkstra求最短路)

实验电镜距离测量之Matlab处理

Hdu1236 ranking (structure Sorting)
![[AGC] build service 3 - authentication service example](/img/89/63f367270e806e89c4ff92360dc3c5.png)
[AGC] build service 3 - authentication service example
随机推荐
Hdu1234 door opener and door closer (water question)
P1055 [NOIP2008 普及组] ISBN 号码
Common methods of JS array
二叉树专题--AcWing 47. 二叉树中和为某一值的路径(前序遍历)
Read H264 parameters from mediarecord recording
洛谷 P5536 【XR-3】核心城市(贪心 + 树形 dp 寻找树的中心)
【深入浅出玩转FPGA学习4----漫谈状态机设计】
flink二開,實現了個 batch lookup join(附源碼)
One trick to quickly realize custom application titlebar
php中self和static在方法中的区别
Nodejs+express+mysql simple blog building
Analysis of hot spots in AI technology industry
Summary of cases of players' disconnection and reconnection in Huawei online battle service
UVM factory mechanism
2022爱分析· 国央企数字化厂商全景报告
【ARK UI】HarmonyOS ETS的启动页的实现
PCL 从一个点云中提取一个子集
[applinking practical case] share in app pictures through applinking
Use Huawei performance management service to configure the sampling rate on demand
Leetcode 182 Find duplicate email (2022.07.01)