Add solution for problem 63.

This commit is contained in:
Jesse D. McDonald 2015-09-05 12:21:18 -05:00
parent 20472682ac
commit f3f4b456ab
1 changed files with 6 additions and 0 deletions

6
Problem063.hs Normal file
View File

@ -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) ]