Problem
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, $a^2 + b^2 = c^2$. For example, $3^2 + 4^2 = 9 + 16 = 25 = 5^2$. There exists exactly one Pythagorean triplet for which $a + b + c = 1000$.
Find the product $abc$.
Code in Haskell
Euler_009.hs
module Main where
stream = [ (a,b,1000-(a+b),a*b,a*b*(1000-a-b))
| a<-[1..500], b<-[1..500], a<b, b<(1000-a-b) ]
isPythTriple (a,b,c,d,e) = d == 1000*(500-c)
main = print answer
where answer = head $ filter isPythTriple stream
Answer
3******0