For38. An integer \(N (>0)\) is given. Find the amount
\(1^N + 2^{N-1} + ... + N^1\).
To avoid integer overflow, calculate the summands of this sum by using a real variable and print the result as a real number.

Solution in Python 3:

import random

N = random.randrange(1,11)

print("N = ",N)
print()

s = 0
for i in range(1,N+1):
p = 1.0
K = N + 1 - i
for j in range(0,K):
p *= i
s += p
print("i = ",i)
print("j = ",j)
print("p = ",p)
print("s = ",s)
print()

print("Sum = ",s)