Skip to content

Instantly share code, notes, and snippets.

@akoskovacs
Created June 2, 2013 19:35
Show Gist options
  • Save akoskovacs/5694632 to your computer and use it in GitHub Desktop.
Save akoskovacs/5694632 to your computer and use it in GitHub Desktop.
Viéte Pi approximation algorithm in Haskell
make_pi :: Int -> Double
make_pi n = product [2.0/(a x)|x <- [0..n]] where
a 0 = 1.0
a 1 = sqrt 2
a n = sqrt(2+(a (n-1)))
@akoskovacs
Copy link
Author

Usage: make_pi 100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment