problem38
パンデジタル数になるのは 少なくともn<=9
連結される数はn=2のとき、最初が4桁と次が5桁になるので 4999
import Data.List main = print $ maximum $concat $ map g [9..9999] f::Int->Int->Int f x y = read $foldl (++) [] $map show $zipWith (*) [x,x..] [1..y] g x = filter isPandigital $ map (x `f`) [2..9] isPandigital x = "123456789" == ( sort $ show x)
concatしているところと isPandigital がちょっとダサイがまあいいでしょう。
Prelude Main> 932718654 (1.26 secs, 2637538728 bytes)