Sum of K powers
Write a program to print the sum of the
The first line of input is an integer
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.
N=int(input())
K=int(input())
sumResult=0
for number in range(1,N+1):
sumResult+=pow(number,K)
print(sumResult)
Comments
Good
Leave a comment