Created
March 16, 2024 02:41
-
-
Save tallpeak/5558b2f02429688fe5c24b9fa3100632 to your computer and use it in GitHub Desktop.
digits of pi
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 | |
pidigits digits = sum (map piterm [1..(digits - digits `div` 5)]) where | |
kk = 10 ^ digits | |
piterm k = kk * 16*(-1)^(k+1)`div`((2*k-1)*5^(2*k-1)) - kk * 4*(-1)^(k+1)`div`((2*k-1)*239^(2*k-1)) | |
main = do | |
args <- getArgs | |
let digits :: Integer = read (head args) | |
print $ pidigits digits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment