"""
Recursive approach
"""

# Define a recursive function to convert a binary string to an integer.
# Arguments:
# - b: The binary string to convert.
# - power: The power of 2 corresponding to the current binary digit's position (default is 1 for the least significant bit).


def bin2int(b, power=1):
    # Base case: If the string is empty, return 0.
    if len(b) == 0:
        return 0
    # Recursive case: Compute the value of the last binary digit of 'b',
    # multiply it by its positional value (power), and add the result
    # of conversion to the result of the rest of the recursive calls.
    return bin2int(b[0:-1], power * 2) + int(b[-1]) * power


# Prompt the user to input a binary number as a string.
binary_string = input("Please enter the binary representation of a number: ")

# Compute and display the decimal representation of the user's binary number.
print(f"The decimal representation of your number is {bin2int(binary_string)}")
