It turns out that the function is monotonically nondecreasing on the given interval, so we can skip the 9 individual calculations and use only the biggest value for \(n=9\) which is \(k< 21.85\). With the constrained bounds we can formulate a pretty fast brute-force algorithm:

Another way of thinking of the problem is this. Again, from the definition of \(L\) we know that \(10^{k-1}\leq n^k<10^k\). Since \(n<10\), \(10^{k-1}\) grows faster than \(n^k\) and will eventually surpass \(n^k\). All we have to find is the point where they meet:

Surprisingly, we saw this expression earlier for the boundary check, but here it means the number of numbers that meet the requirement. All we still have to do is rounding down the result to get the largest integer for which the inequality holds true. A new much faster algorithm then is this: