当前位置:网站首页>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 .
边栏推荐
- 【ARK UI】HarmonyOS ETS的启动页的实现
- 【快应用】Win7系统使用华为IDE无法运行和调试项目
- 二叉树专题--AcWing 1589. 构建二叉搜索树
- static 函数中的静态变量
- Overview of integrated learning
- Special topic of binary tree -- acwing 1589 Building binary search tree
- Matlab processing of distance measurement of experimental electron microscope
- Huawei game failed to initialize init with error code 907135000
- 二叉树专题--AcWing 19. 二叉树的下一个节点(找树中节点的后继)
- JVM之垃圾回收器
猜你喜欢

Open the encrypted SQLite method with sqlcipher

最详细MySql安装教程

Special topic of binary tree -- acwing 3384 Binary tree traversal (known preorder traversal, while building a tree, while outputting middle order traversal)

【深入浅出玩转FPGA学习5-----复位设计】

二叉树专题--AcWing 1497. 树的遍历(利用后、中序遍历,构建二叉树)

Thanos Receiver

JVM之垃圾回收器

【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决

如何用list组件实现tabbar标题栏
![[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]
随机推荐
1287_ Implementation analysis of prvtaskistasksuspended() interface in FreeRTOS
Logu p3398 hamster looks for sugar (double LCA on the tree to judge whether the two paths in the tree intersect)
[visual studio] visual studio 2019 community version cmake development environment installation (download | install relevant components | create compilation execution project | error handling)
二叉树专题--AcWing 1497. 树的遍历(利用后、中序遍历,构建二叉树)
Luogu p5536 [xr-3] core city (greed + tree DP looking for the center of the tree)
Easyexcel, a concise, fast and memory saving excel processing tool
C#中索引器
[quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
【深入浅出玩转FPGA学习4----漫谈状态机设计】
如何使用IDE自动签名调试鸿蒙应用
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
Open the encrypted SQLite method with sqlcipher
[play with FPGA learning 4 in simple terms ----- talk about state machine design]
AppGallery Connect场景化开发实战—图片存储分享
Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)
HDU1228 A + B(map映射)
P1055 [noip2008 popularization group] ISBN number
K-d tree and octree of PCL
TIPC Cluster5
[in simple terms, play with FPGA learning 3 ----- basic grammar]