Part of the series

Several example codes

~1 min read • Updated Oct 12, 2025

Program Overview

This Python program reads two values m11 and m12 and calculates C^m using a recursive function.
Here, C = m11 and m = m12.


Python Code:


def power_recursive(C: int, m: int) -> int:
    if m == 0:
        return 1
    return C * power_recursive(C, m - 1)

# Read inputs from user
m11 = int(input("Enter m11 (base): "))
m12 = int(input("Enter m12 (exponent): "))

result = power_recursive(m11, m12)
print(f"{m11}^{m12} = {result}")

Sample Output (input: m11 = 2, m12 = 5):


2^5 = 32

Written & researched by Dr. Shahin Siami