Project Euler 63: Count how many ndigit positive integers exist which are also an nth power
Problem Description
The 5digit number, 16807=7^{5}, is also a fifth power. Similarly, the 9digit number, 134217728=8^{9}, is a ninth power.
How many ndigit positive integers exist which are also an nth power?
Analysis
One way to know how many digits a number has is to use the formula: int(log_{10} n) +1. For this problem n cannot be greater than 10 since 10^{n} is always n+1 digits long.
So we need to create a function such that f(n) = upper limit of n. Using our log function and using 9 as an example we define f(9) as int (1 / (1 – log_{10} 9)) or 21 such that 9^{n} < 10^{n1}. Thus 9^{n} is n digits long when n ≤ 21. We repeat this same process for 1 through 8 and sum the results for an answer.
Project Euler 63 Solution
Runs < 0.001 seconds in Python 2.7.Use this link to get the Project Euler 63 Solution Python 2.7 source.
Afterthoughts

No afterthoughts yet.
Discussion
No comments yet.