Advertisement
Guest User

Untitled

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