当前位置:网站首页>2.3 partial sum of square and reciprocal sequences
2.3 partial sum of square and reciprocal sequences
2022-06-25 19:57:00 【Then peace and happiness】
This problem requires two positive integers m and n(m≤n) Programming , Calculate the sequence and .

Input format :
Enter two positive integers on one line m and n(m≤n), They are separated by spaces .
Output format :
In a row, press “sum = S” The format of the output part and the value of S, To six decimal places . The calculation results should not exceed the double precision range .
sample input :
5 10
sample output :
sum = 355.845635Code :
#include <stdio.h>
#include <math.h>
int main ()
{
int m,n;
scanf("%d %d",&m,&n);
double sum1=0.0, sum2=0.0, sum;
int i;
for(i=m;i<=n;i++){
sum1=sum1+i*i;
sum2=sum2+1.0/i;
}
sum=sum1+sum2;
printf("sum = %.6f",sum);
return 0;
}
边栏推荐
- Vulnhub range the planes: mercury
- Is it safe to open a new bond account
- 2.15(Multiple of 3 Or 5)
- 2020-12-09 laravel . Env file loading mechanism process
- Redis cache preheating & avalanche & breakdown & penetration
- Applet canvas generate sharing Poster
- JS mobile phone and computer open different websites
- Android Development Notes - Quick Start (from sqllite to room licentiousness) 2
- Arduino : No such file or directory
- 2.16([Usaco2005 Nov]Ant Counting)
猜你喜欢

Wechat applet swiper simple local picture display appears large blank

Uni app through uni Navigateto failed to pass parameter (pass object)

Jsonp function encapsulation

ECS 7-day practical training camp (Advanced route) -- day01 -- setting up FTP service based on ECS

Vulnhub range - the planes:venus

Ali visual AI training camp -day03- construction of electronic photo album (face and expression recognition)

Profile path and name

Automatic fitting when the applet reaches the top

Vulnhub range the planes:earth

Applet canvas generate sharing Poster
随机推荐
PAT B1071
Miner's Diary: why should I go mining on April 5, 2021
Single chip microcomputer line selection method to store impression (address range) method + Example
Vulnhub range - darkhole 1
New features of php7
Apifox simple understanding -- the integrator of web side testing
DARKHOLE 2
Install spoole
PAT B1053
Ali vision AI training camp-day01
Principles of MySQL clustered index and non clustered index
PAT B1076
Native JS array some method de duplication
Vulnhub range the planes:earth
Vulnhub range - correlation:2
wooyun-2014-065513
六、HikariConfig的配置解析
Some pictures of real machine preview development and debugging are not shown
Is it safe to open a new bond? Is low commission reliable
Vulnhub range the planes: mercury