Project Euler Problem 063
import Data.List -- a>=10になると、2n桁以上になるので、aはnまでテストすれば良い -- nはtakeWhileで条件を満たすまでとる lst :: [Integer] lst = [a^n | a <- [1..9], n<-takeWhile (\x -> x == (length $ show(a^x))) [1..]] ans1 :: Int ans1 = length lst -- 49 main :: IO () main = print ans1 --全リスト --[1,2,3,4,16,5,25,125,6,36,216,1296,7,49,343,2401,16807,117649,8,64,512,4096,32768,262144,2097152,16777216,134217728,1073741824,9,81,729,6561,59049,531441,4782969,43046721,387420489,3486784401,31381059609,282429536481,2541865828329,22876792454961,205891132094649,1853020188851841,16677181699666569,150094635296999121,1350851717672992089,12157665459056928801,109418989131512359209]