当前位置:网站首页>功能:编写函数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);
}
边栏推荐
- What does redis do? Redis often practices grammar every day
- Interview script of Software Test Engineer
- Is the account opening of Guoyuan securities really safe and reliable
- [about text classification trick] things you don't know
- Regular expressions and text processors for shell programming
- How to be a professional software testing engineer? Listen to the byte five year old test
- 【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
- [C language] break and continue in switch statement
- Global and Chinese market of breast cancer imaging 2022-2028: Research Report on technology, participants, trends, market size and share
- (Video + graphics and text) introduction to machine learning series - Chapter 4 naive Bayes
猜你喜欢

Struct in linked list

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

Tencent interview: can you find the number of 1 in binary?

Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival

Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?

Is it really possible that the monthly salary is 3K and the monthly salary is 15K?

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

Research Report on the scale prediction of China's municipal engineering industry and the prospect of the 14th five year plan 2022-2028

How will the complete NFT platform work in 2022? How about its core functions and online time?
![[PHP basics] session basic knowledge, application case code and attack and defense](/img/f5/713d7044a693ef23e3fbb1ff9bc9f4.jpg)
[PHP basics] session basic knowledge, application case code and attack and defense
随机推荐
Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
How will the complete NFT platform work in 2022? How about its core functions and online time?
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Iclr2022: how does AI recognize "things I haven't seen"?
Test the influence of influent swacth on the electromagnetic coil of quartz meter
A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders
Solution to the impact of Remote Code Execution Vulnerability of log4j2 component on December 9, 2021
Similarities and differences of text similarity between Jaccard and cosine
Gossip about redis source code 78
Gossip about redis source code 81
[NLP] text classification still stays at Bert? Duality is too strong than learning framework
Investment demand and income forecast report of China's building ceramics industry, 2022-2028
How to trade spot gold safely?
It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something
Kubedl hostnetwork: accelerating the efficiency of distributed training communication
Global and Chinese market of breast cancer imaging 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of glossometer 2022-2028: Research Report on technology, participants, trends, market size and share
Suggestions for improving code quality
[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections
What is the Valentine's Day gift given by the operator to the product?