dmjio
8/29/2011 - 12:44 AM

Calculating all factorials of numbers 1 to 51,000

Calculating all factorials of numbers 1 to 51,000


open System
open System.Diagnostics

let rec fac x = if x < 1.0 then 1.0 else x * fac(x-1.0)

let watch = new Stopwatch()
watch.Start()
let complexComputation = Async.Parallel [for i in 0.0..51000.0 -> async { return fac(i) }] |> Async.RunSynchronously;;
watch.Stop()
let result = watch.Elapsed.Seconds.ToString()
printfn "%s" result;;