当前位置:网站首页>Function: write function fun to find s=1^k+2^k +3^k ++ The value of n^k, (the cumulative sum of the K power of 1 to the K power of n).
Function: write function fun to find s=1^k+2^k +3^k ++ The value of n^k, (the cumulative sum of the K power of 1 to the K power of n).
2022-07-04 00:41:00 【CTGU-Yoghurt】
subject :
Code details :
#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);
}
边栏推荐
- 1214 print diamond
- Struct in linked list
- Axure resources and prototype tool Axure RP 9 download
- The difference between fetchtype lazy and eagle in JPA
- On covariance of array and wildcard of generic type
- [complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
- [cloud native topic -48]:kubesphere cloud Governance - operation - overview of multi tenant concept
- system. Exit (0) and system exit(1)
- Bodong medical sprint Hong Kong stocks: a 9-month loss of 200million Hillhouse and Philips are shareholders
- Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
猜你喜欢
Gauss elimination method and template code
Regular expressions and text processors for shell programming
It's OK to have hands-on 8 - project construction details 3-jenkins' parametric construction
老姜的特点
MySQL winter vacation self-study 2022 12 (1)
The super fully automated test learning materials sorted out after a long talk with a Tencent eight year old test all night! (full of dry goods
[GNN] hard core! This paper combs the classical graph network model
The FISCO bcos console calls the contract and reports an error does not exist
[about text classification trick] things you don't know
Future source code view -juc series
随机推荐
Analysis: misunderstanding of choosing WMS warehouse management system
[software testing] you haven't mastered these real interview questions of big companies?
Axure resources and prototype tool Axure RP 9 download
网上的低佣金链接安全吗?招商证券怎么开户?
ITK learning notes (VII) the position of ITK rotation direction remains unchanged
MySQL winter vacation self-study 2022 12 (1)
Is it really possible that the monthly salary is 3K and the monthly salary is 15K?
A method to solve Bert long text matching
[prefix and notes] prefix and introduction and use
How to be a professional software testing engineer? Listen to the byte five year old test
The difference between objects and objects
Development and application of fcitx functional plug-ins
[dynamic programming] leetcode 53: maximum subarray sum
leetcode 121 Best Time to Buy and Sell Stock 买卖股票的最佳时机(简单)
AI Challenger 2018 text mining competition related solutions and code summary
Test the influence of influent swacth on the electromagnetic coil of quartz meter
Qtcharts notes (V) scatter diagram qscatterseries
A-Frame虚拟现实开发入门
GUI 应用:socket 网络聊天室
Is the low commission link on the internet safe? How to open an account for China Merchants Securities?