Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.Ratio
- myPi :: Int -> Double
- myPi seriesLength = fromRational piRatApprox
- where piRatApprox = (* toRational 4)
- . sum
- . take seriesLength
- . map (\n -> 1 % n)
- . iterate (\n -> -1 * (n + signum n * 2))
- $ 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement