Algorithm Implementation in FSharp