Problem 63 solved
This commit is contained in:
parent
e7200623fc
commit
e4baa3e67a
1 changed files with 15 additions and 0 deletions
15
063.hs
Normal file
15
063.hs
Normal file
|
@ -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]
|
Loading…
Reference in a new issue