Last active
April 20, 2019 23:43
-
-
Save alaztetik/9b42e5a3e360c8574c9ce4f0a2366ea0 to your computer and use it in GitHub Desktop.
Leibniz PI Formula
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
// REV 03-19042101 | |
function pi(n) { | |
var v = 0; | |
for (i = 1; i <= n; i += 4) { // increment by 4 | |
v += 1 / i - 1 / (i + 2); // add the value of the series | |
} | |
return 4 * v; // apply the factor at last | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment