Skip to content

Instantly share code, notes, and snippets.

@dripolles
Last active August 29, 2015 14:15
Show Gist options
  • Save dripolles/348b817dbdfc5b0086b3 to your computer and use it in GitHub Desktop.
Save dripolles/348b817dbdfc5b0086b3 to your computer and use it in GitHub Desktop.
import Data.Number.CReal
nilakantha :: Int -> CReal
nilakantha n = 3 + (sum $ take n series) where
series = zipWith (\sign d -> (-1) * sign * 4 / d) (cycle [-1,1]) denominators
denominators = map (\x -> x * (x+1) * (x+2)) [2,4..] :: [CReal]
main = print $ nilakantha 150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment