For37. An integer \(N (>0)\) is given. Find the sum
\(1^1 + 2^2 + ... + N^N\).
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
for j in range(1,i+1):
p *= i
s += p
print("i = ",i)
print("p = ",p)
print("s = ",s)
print()

print("Sum = ",s)