Problem 62

Powerful digit counts

Problem 64

Powerful digit counts

Problem 63

The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power.
How many n-digit positive integers exist which are also an nth power?
def run():
    found = 0
    for power in range(1, 22):
        for i in range(1, 10):
            d = i**power
            if len(str(d)) == power:
                found += 1

    return found