Project Euler 63 - Powerful digit counts

Official link:

Thought Process

The first thing I noticed was 10^n will always result in a number that is n+1 digits long. This means we can only have 1,2,3,4,5,6,7,8,9 ^ n, we can find upper bounds for all of these numbers as well, all we need to do is find the first number, i, such that i > len(str(9^i)).

For n = 9, it is i = 22 because 9^22 = 984770902183611232881 which only has 21 digits, but it is to the 22nd power.

As you can see now, all we need to do is go through n, from 1 to 9, and i, from 1 to 22 and if i = len(str(n**i)) then we have found an n-digit integer which is also an nth power.

Interactive Code

No interactive code for this problem, my code is shown below