This Python program reads an integer n and computes the result of the following series:
∑ [(n - k) · k^(n - k)] for k from 1 to n
Each term multiplies a linear coefficient by a power of k.
def compute_series(n: int) -> int:
total = 0
for k in range(1, n + 1):
term = (n - k) * (k ** (n - k))
total += term
return total
# Read input from user
n = int(input("Enter value for n: "))
result = compute_series(n)
print(f"Series result is: {result}")
Series result is: 78