当前位置:网站首页>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 .
边栏推荐
- From Read and save in bag file Jpg pictures and PCD point cloud
- flink二开,实现了个 batch lookup join(附源码)
- JVM garbage collector
- TIPC Cluster5
- 如何使用IDE自动签名调试鸿蒙应用
- nodejs+express+mysql简单博客搭建
- 【深入浅出玩转FPGA学习3-----基本语法】
- Leetcode 182 Find duplicate email (2022.07.01)
- [ark UI] implementation of the startup page of harmonios ETS
- 【ARK UI】HarmonyOS ETS的启动页的实现
猜你喜欢

Analysis of hot spots in AI technology industry

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

Nodejs+express+mysql simple blog building

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

首份中国企业敏捷实践白皮书发布| 附完整下载

Uncover the secrets of Huawei application market application statistics

How to transfer event objects and user-defined parameters simultaneously in Huawei express applications

全网显示 IP 归属地,是怎么实现的?

The most detailed MySQL installation tutorial

1287_ Implementation analysis of prvtaskistasksuspended() interface in FreeRTOS
随机推荐
二叉树专题--AcWing 47. 二叉树中和为某一值的路径(前序遍历)
[AGC] build service 3 - authentication service example
flink二開,實現了個 batch lookup join(附源碼)
Special topic of binary tree -- acwing 3540 Binary search tree building (use the board to build a binary search tree and output the pre -, middle -, and post sequence traversal)
二叉树专题--AcWing 1497. 树的遍历(利用后、中序遍历,构建二叉树)
[quick application] win7 system cannot run and debug projects using Huawei ide
The most detailed MySQL installation tutorial
最详细MySql安装教程
一招快速实现自定义快应用titlebar
Use Huawei performance management service to configure the sampling rate on demand
二叉树专题--【深基16.例7】普通二叉树(简化版)(multiset 求前驱 后继 哨兵法)
PCL eigen introduction and simple use
Special topic of binary tree -- acwing 47 Path with a certain value in binary tree (preorder traversal)
二叉树专题--AcWing 3384. 二叉树遍历(已知先序遍历 边建树 边输出中序遍历)
Oracle 笔记
VSCode工具使用
洛谷 P4281 [AHOI2008]紧急集合 / 聚会(树上倍增 LCA)
[applinking practical case] share in app pictures through applinking
OpenMLDB Meetup No.4 会议纪要
软件产品管理系统有哪些?12个最佳产品管理工具盘点