当前位置:网站首页>功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
2022-07-04 00:33:00 【CTGU-Yoghurt】
题目:
代码详解:
#define K 4
#define N 5
#include <stdio.h>
long fun(int n, int k)
{
/**********Program**********/
long sum = 1,i,j,t;
for (i = 2; i <= n; i++)
{
t = 1;
for (j = 1; j <= k; j++)
{
t *= i;
}
sum += t;
}
return sum;
/********** End **********/
}
int main()
{
long int sum;
printf("Sum of %d powers of integers from 1 to %d = ", K, N);
sum = fun(N, K);
printf("%ld\n", sum);
}
边栏推荐
- Report on the construction and development mode and investment mode of sponge cities in China 2022-2028
- Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
- Global and Chinese markets of distributed control system (DCS) consumption 2022-2028: Research Report on technology, participants, trends, market size and share
- STM32 key light
- Selenium library 4.5.0 keyword explanation (II)
- The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
- 8. Go implementation of string conversion integer (ATOI) and leetcode
- Idea set class header comments
- Kubedl hostnetwork: accelerating the efficiency of distributed training communication
- Double efficiency. Six easy-to-use pychar plug-ins are recommended
猜你喜欢

Pytest unit test framework: simple and easy to use parameterization and multiple operation modes

What does redis do? Redis often practices grammar every day

It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something

SPI based on firmware library
![[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!](/img/28/fc05f2e8d53cf81fd061c799090022.jpg)
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!

STM32 GPIO CSDN creative punch in

2022 system integration project management engineer examination knowledge points: software development model

Self study software testing. To what extent can you go out and find a job?

It is forbidden to splice SQL in code

(Video + graphics and text) introduction to machine learning series - Chapter 4 naive Bayes
随机推荐
Gossip about redis source code 77
Self study software testing. To what extent can you go out and find a job?
Global and Chinese markets of distributed control system (DCS) consumption 2022-2028: Research Report on technology, participants, trends, market size and share
UTS | causal reasoning random intervention based on Reinforcement Learning
Report on the construction and development mode and investment mode of sponge cities in China 2022-2028
(Introduction to database system | Wang Shan) Chapter V database integrity: Exercises
Generic
ISBN number
China standard gas market prospect investment and development feasibility study report 2022-2028
(Video + graphics and text) introduction to machine learning series - Chapter 4 naive Bayes
P1629 postman delivering letter
Version rollback revert don't reset better reset must be forced
Att & CK actual combat series - red team actual combat - V
Entropy and full connection layer
Kubedl hostnetwork: accelerating the efficiency of distributed training communication
How to be a professional software testing engineer? Listen to the byte five year old test
Detailed explanation of the relationship between Zhongtai, wechat and DDD
1214 print diamond
Solve the problem that the kaggle account registration does not display the verification code
Smart fan system based on stm32f407