the 5digit number 1680775 is also a fifth power similarly the 9digit number 13421772889 is a ninth power how many ndigit positive integers exist which are also an nth power the maximum base can be 9 because all ndigit numbers 10n now 923 has 22 digits so the maximum power can be 22 using these conclusions we will calculate the result returns the count of all ndigit numbers which are nth power solution10 22 49 solution0 0 0 solution1 1 0 solution1 1 0 the maximum base can be 9 because all n digit numbers 10 n now 9 23 has 22 digits so the maximum power can be 22 using these conclusions we will calculate the result returns the count of all n digit numbers which are nth power solution 10 22 49 solution 0 0 0 solution 1 1 0 solution 1 1 0
def solution(max_base: int = 10, max_power: int = 22) -> int:
    
    bases = range(1, max_base)
    powers = range(1, max_power)
    return sum(
        1 for power in powers for base in bases if len(str(base**power)) == power
    )


if __name__ == "__main__":
    print(f"{solution(10, 22) = }")