<Query Kind="FSharpProgram" />

// http://t0yv0.blogspot.com/2011/12/solving-f-asyncstartchild-leak-futures.html

let rec fib n = async {
    if n < 2 then
        return 1
    else
        let! x' = Async.StartChild (fib (n-2))
        let! y = fib (n-1)
        let! x = x'
        return x + y
    }

for n in [0..10] do
    let f = fib n |> Async.RunSynchronously
    printfn "fib %d = %d" n f