当前位置:网站首页>功能:编写函数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);
}
边栏推荐
- Several ways to set up a blog locally [attach relevant software download links]
- What is the GPM scheduler for go?
- 8. Go implementation of string conversion integer (ATOI) and leetcode
- STM32 key light
- A dichotomy of Valentine's Day
- [C language] break and continue in switch statement
- A method to solve Bert long text matching
- Introduction to thread pool
- What is the difference between NFT, SFT and dnft? How to build NFT platform applications?
- Sorry, Tencent I also refused
猜你喜欢

SPI based on firmware library

A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders

Att & CK actual combat series - red team actual combat - V

Detailed explanation of the relationship between Zhongtai, wechat and DDD

What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers

Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn

Introducing Software Testing

Yyds dry goods inventory three JS source code interpretation - getobjectbyproperty method

Smart fan system based on stm32f407

Report on the construction and development mode and investment mode of sponge cities in China 2022-2028
随机推荐
Introduction to thread pool
Bodong medical sprint Hong Kong stocks: a 9-month loss of 200million Hillhouse and Philips are shareholders
P1339 [USACO09OCT]Heat Wave G
How to make recv have a little temper?
Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn
Vscode regular match replace console log(.*)
Gossip about redis source code 74
After the Lunar New Year and a half
Software testers, how can you quickly improve your testing skills? Ten minutes to teach you
Global and Chinese markets for coronary artery disease treatment devices 2022-2028: Research Report on technology, participants, trends, market size and share
Is user authentication really simple
[error record] configure NDK header file path in Visual Studio
Tencent interview: can you find the number of 1 in binary?
URL (data:image/png; Base64, ivborw0k... Use case
STM32 key light
Makefile judge custom variables
[cloud native topic -48]:kubesphere cloud Governance - operation - overview of multi tenant concept
Selenium library 4.5.0 keyword explanation (III)
China standard gas market prospect investment and development feasibility study report 2022-2028
Selenium library 4.5.0 keyword explanation (I)