当前位置:网站首页>功能:编写函数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);
}
边栏推荐
- Generic tips
- UTS | causal reasoning random intervention based on Reinforcement Learning
- Is it really possible that the monthly salary is 3K and the monthly salary is 15K?
- China standard gas market prospect investment and development feasibility study report 2022-2028
- Arc 135 supplementary report
- ISBN number
- Global and Chinese markets of distributed control system (DCS) consumption 2022-2028: Research Report on technology, participants, trends, market size and share
- 【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
- Distributed transaction -- middleware of TCC -- selection / comparison
- Global and Chinese markets for coronary artery disease treatment devices 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
Several ways to set up a blog locally [attach relevant software download links]
A method to solve Bert long text matching
Solve the problem that the kaggle account registration does not display the verification code
NLP Chinese corpus project: large scale Chinese natural language processing corpus
[C language] break and continue in switch statement
Report on the construction and development mode and investment mode of sponge cities in China 2022-2028
Zipper table in data warehouse (compressed storage)
Joint examination of six provinces 2017
[NLP] text classification still stays at Bert? Duality is too strong than learning framework
ESP Arduino playing with peripherals (V) basic concept of interrupt and timer interrupt
随机推荐
Vscode regular match replace console log(.*)
(Video + graphics and text) introduction to machine learning series - Chapter 4 naive Bayes
Makefile judge custom variables
CSP window
Pytorch learning notes 5: model creation
Recommendation of knowledge base management system
Alibaba test engineer with an annual salary of 500000 shares notes: a complete set of written tests of software testing
Report on prospects and future investment recommendations of China's assisted reproductive industry, 2022-2028 Edition
Analysis: misunderstanding of choosing WMS warehouse management system
BBS forum recommendation
[leetcode] interview question 17.08 Circus tower
Zipper table in data warehouse (compressed storage)
Bodong medical sprint Hong Kong stocks: a 9-month loss of 200million Hillhouse and Philips are shareholders
A dichotomy of Valentine's Day
Optimization of for loop
网上的低佣金链接安全吗?招商证券怎么开户?
Gossip about redis source code 81
How will the complete NFT platform work in 2022? How about its core functions and online time?
Interview script of Software Test Engineer
Is the securities account opened by Caicai for individuals safe? Is there a routine