Project Euler Problem 009
import Control.Monad import Control.Applicative import Data.List wa :: Num a => (a, a, a) -> a wa (a,b,c) = a+b+c prod :: Num a => (a, a, a) -> a prod (a,b,c) = a*b*c l :: [Integer] l = [5..32] --bの範囲。3,5,...となり32^2>1000 --ピタゴラス数生成の漸化式 pita = prod $ last $ filter ((==1000).wa) [(m*m-n*n,2*m*n,m*m+n*n)|m<-l,n<-l,n[(a-2*b+2*c, 2*a-b+2*c, 2*a-2*b+3*c), (a+2*b+2*c, 2*a+b+2*c, 2*a+2*b+3*c), (-a+2*b+2*c, -2*a+b+2*c, -2*a+2*b+3*c)]) pita4 :: [(Integer,Integer,Integer)]