Skip to content

Instantly share code, notes, and snippets.

@andiogenes
Created June 14, 2019 02:42
Show Gist options
  • Save andiogenes/37a77a8e61ae030c85479f4446a64204 to your computer and use it in GitHub Desktop.
Save andiogenes/37a77a8e61ae030c85479f4446a64204 to your computer and use it in GitHub Desktop.
let lnPrec x eps =
Seq.unfold (fun (s, n) ->
if (s/(float n) < eps) then None
else Some( (s, n), (s*(x-1.0)/x, n+1) )) ((x-1.0)/x, 1)
|> Seq.fold (fun acc (s, n) -> acc + s/(float n)) 0.0
let lnRange x range =
Seq.unfold (fun (s, n) ->
if (n > range) then None
else Some( (s, n), (s*(x-1.0)/x, n+1) )) ((x-1.0)/x, 1)
|> Seq.fold (fun acc (s,n) -> acc + s/(float n)) 0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment