Last active
December 9, 2015 16:25
-
-
Save alkhe/0f5cf9fde718e4010115 to your computer and use it in GitHub Desktop.
calculate pi with arctan series
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
let summation = (start, end, a) => { | |
let sum = 0; | |
for (let n = start; n <= end; n++) sum += a(n); | |
return sum; | |
} | |
console.log(4 * summation(0, 100000000, n => (n & 1 === 1 ? -1 : 1) / (2 * n + 1))); // 3.141592663589326 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment