File size: 462 Bytes
e1dfd79 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | def power(x, n):
if n == 0:
return 1
else:
return x * power(x, n - 1)
print("\tComputing power function using trivial recursion (x^n)")
print("\t-------------------------------------------------")
print("Input")
print("------")
x = int(input("Enter the base value x: "))
n = int(input("Enter the exponential value n: "))
r = power(x, n)
print("Output")
print("-------")
print("The value of", x, "power", n, "=", r)
|