Skip to content

Instantly share code, notes, and snippets.

@javascripter
Created July 28, 2009 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javascripter/156960 to your computer and use it in GitHub Desktop.
Save javascripter/156960 to your computer and use it in GitHub Desktop.
import System.Environment
import Ratio
main = do
args <- getArgs
print $ pi' $ read $ head args
pi' x = fromRational (foldl f 0 [1,5..x] * 4)
where
f x y = x + (1 % y) - 1 % (y + 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment