Answer to Question #219373 in Python for chandu

Question #219373

Sum of K powers

Write a program to print the sum of the

Kth power of the first N natural numbers.Input

The first line of input is an integer

N. The second line of input is an integer K.Explanation

In the given example, the sum of first

5 natural numbers power of 3.The sum should be 13 + 23 + 33 + 43 + 53

Therefore, the output should be

225.


1
Expert's answer
2021-07-22T18:42:31-0400
N=int(input())
K=int(input())
sumResult=0
for number in range(1,N+1):
    sumResult+=pow(number,K)
print(sumResult)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Mohini Jagdish Ramteke
17.04.23, 20:14

Good

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS