Created
June 14, 2019 02:42
-
-
Save andiogenes/37a77a8e61ae030c85479f4446a64204 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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