From f3f4b456ab7e5333de102d54e820708c16179491 Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Sat, 5 Sep 2015 12:21:18 -0500 Subject: [PATCH] Add solution for problem 63. --- Problem063.hs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Problem063.hs 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) ]