当前位置:网站首页>功能:编写函数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);
}
边栏推荐
- Solution to the impact of Remote Code Execution Vulnerability of log4j2 component on December 9, 2021
- What does redis do? Redis often practices grammar every day
- A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders
- Gossip about redis source code 74
- MySQL winter vacation self-study 2022 12 (2)
- Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
- Idea set class header comments
- Data storage - interview questions
- It is forbidden to splice SQL in code
- Correlation analysis summary
猜你喜欢
Idea a method for starting multiple instances of a service
A dichotomy of Valentine's Day
Alibaba test engineer with an annual salary of 500000 shares notes: a complete set of written tests of software testing
[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections
STM32 key light
Recommendation of knowledge base management system
Makefile judge custom variables
What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers
MySQL winter vacation self-study 2022 12 (1)
Idea set class header comments
随机推荐
[C language] break and continue in switch statement
Zipper table in data warehouse (compressed storage)
Selenium library 4.5.0 keyword explanation (I)
Eight year test old bird, some suggestions for 1-3 year programmers
Qtcharts notes (V) scatter diagram qscatterseries
[PHP basics] cookie basics, application case code and attack and defense
Shell script three swordsman sed
Selenium library 4.5.0 keyword explanation (II)
Global and Chinese market of underwater bags 2022-2028: Research Report on technology, participants, trends, market size and share
From functional testing to automated testing, how did I successfully transform my salary to 15K +?
Entropy and full connection layer
system. Exit (0) and system exit(1)
After the Lunar New Year and a half
NLP Chinese corpus project: large scale Chinese natural language processing corpus
Gossip about redis source code 75
[Mongodb] 2. Use mongodb --------- use compass
Similarities and differences of text similarity between Jaccard and cosine
Self study software testing. To what extent can you go out and find a job?
Vscode regular match replace console log(.*)
[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections