| 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) | |