Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rec :: Rational -> Bool -> [Integer] -> Rational
- rec currSum _ [] = currSum
- rec currSum add (n:ns) | add = rec (currSum + (1%n)) (not add) ns
- | otherwise = rec (currSum - (1%n)) (not add) ns
- odds :: [Integer]
- odds = [1,3..]
- myPi2 seriesLength = fromRational $ 4 * rec 0 True (take seriesLength odds)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement