-- How many n-digit positive integers exist which are also an nth power? import Data.List (nub) -- If x >= 10 then x^n >= 10^n and thus has more than n digits. -- If n >= 22 then 9^n < 10^(n-1) and thus has fewer than n digits. main = print $ length $ nub [ x^n | n <- [1..21], x <- [1..9], x^n >= 10^(n-1) ]