Skip to content

Instantly share code, notes, and snippets.

@calebeby
Last active May 3, 2017 01:58
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 calebeby/ca290a8ce8dda17c01c6c87452f853bf to your computer and use it in GitHub Desktop.
Save calebeby/ca290a8ce8dda17c01c6c87452f853bf to your computer and use it in GitHub Desktop.
Pi
const iterations = 1000000000
var pi = 0
const getPi = () => {
for (let i = 1; i <= iterations; i += 4) {
pi += 4 / i
pi -= 4 / (i + 2)
}
}
getPi()
console.log(pi)
// 3.141592651589258 after 45s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment