From e4baa3e67aaaba0eb0358a0f48ed65bc01b0326b Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Fri, 9 Dec 2011 14:57:54 +0100 Subject: [PATCH] Problem 63 solved --- 063.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 063.hs diff --git a/063.hs b/063.hs new file mode 100644 index 0000000..460d274 --- /dev/null +++ b/063.hs @@ -0,0 +1,15 @@ +-- Problem 63 +-- 13 February 2004 +-- +-- The 5-digit number, 16807=7^5, is also a fifth power. Similarly, the 9-digit number, 134217728=8^9, is a ninth power. +-- +-- How many n-digit positive integers exist which are also an nth power? + +powers n = map (^n) [1..100] + +is_solution n x = (x >= 10^(n-1)) && (x < 10^n) + +find n = filter (is_solution n) (powers n) + +main = do + print $ sum $ map (length . find) [1..100]