Created
July 28, 2009 05:56
-
-
Save javascripter/156960 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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