当前位置:网站首页>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 .
边栏推荐
- PCL point cloud to depth image
- Hdu1234 door opener and door closer (water question)
- [TS] 1368 seconds understand typescript generic tool types!
- nodejs+express+mysql简单博客搭建
- HDU1234 开门人和关门人(水题)
- [quick application] win7 system cannot run and debug projects using Huawei ide
- JSP webshell free -- the basis of JSP
- Record attributeerror: 'nonetype' object has no attribute 'nextcall‘
- 二叉树专题--AcWing 3540. 二叉搜索树建树(实用板子 构建二叉搜索树 并输出前、中、后序遍历)
- Logu p3398 hamster looks for sugar (double LCA on the tree to judge whether the two paths in the tree intersect)
猜你喜欢

快应用中实现自定义抽屉组件

flink二开,实现了个 batch lookup join(附源码)

One trick to quickly realize custom application titlebar

集成学习概览

TIPC Cluster5

Flink two Open, implement Batch Lookup join (attached source)

二叉树专题--AcWing 3540. 二叉搜索树建树(实用板子 构建二叉搜索树 并输出前、中、后序遍历)

Huawei game failed to initialize init with error code 907135000

Jsp webshell Free from killing - The Foundation of JSP

Analysis of hot spots in AI technology industry
随机推荐
[ark UI] implementation of the startup page of harmonios ETS
二叉树专题--AcWing 19. 二叉树的下一个节点(找树中节点的后继)
P1055 [noip2008 popularization group] ISBN number
PCL 点云转深度图像
PCL之滤波
UVM learning - object attribute of UVM phase
UVM——Callback
JSP webshell免殺——JSP的基礎
HDU1236 排名(结构体排序)
二叉树专题--AcWing 1497. 树的遍历(利用后、中序遍历,构建二叉树)
Oracle 笔记
TIPC Cluster5
[AGC] build service 3 - authentication service example
Point cloud projection picture
二叉树专题--洛谷 P3884 [JLOI2009]二叉树问题(dfs求二叉树深度 bfs求二叉树宽度 dijkstra求最短路)
【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?
【AGC】构建服务3-认证服务示例
The URL in the RTSP setup header of the axis device cannot take a parameter
flink二開,實現了個 batch lookup join(附源碼)
In the face of uncertainty, the role of supply chain