diff --git a/Problem063.hs b/Problem063.hs new file mode 100644 index 0000000..fad5c3f --- /dev/null +++ b/Problem063.hs @@ -0,0 +1,6 @@ +-- 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) ]