I’m beginning to learn F# and the best way for me to go about that is to start applying it. There are some interesting computational problems over at Project Euler . This post is the continuation of a series of posts each involving a separate Project Euler problem. This post involves solutions to Project Euler problem #9.

A Pythagorean triplet is a set of three natural numbers,a<b<c, for which,a+^{2}b=^{2}cFor example, 3^{2}^{2}+ 4^{2}= 9 + 16 = 25 = 5^{2}. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the productabc.

let triplet = seq { for a = 0 to 332 do // since a < b < c the max a can be is 332 for b = a+1 to 499 do // since b < c the max b can be is 499 let c = 1000 - a - b if a*a + b*b = c*c then yield (a, b, c) } |> Seq.hd |