This Python program reads three values x, a, and n from the user and computes the result of a mathematical expression.
The formula may involve exponentiation, division, and summation, implemented via a loop or recursion.
def compute_expression(x: float, a: float, n: int) -> float:
total = 0.0
for k in range(1, n + 1):
term = ((x ** (a + k)) / k) ** k
total += term
return total
# Read inputs from user
x = float(input("Enter value for x: "))
a = float(input("Enter value for a: "))
n = int(input("Enter value for n: "))
result = compute_expression(x, a, n)
print(f"Result of the expression is: {result:.4f}")
Result of the expression is: 1131.1111