Skip to content

Instantly share code, notes, and snippets.

@Lytol
Lytol / pi.js
Last active March 17, 2021 23:53 — forked from ggrumbley/pi.js
// Define a method that rounds pi to a specified decimal place
// Return Pi and how many iterations of the following formula that it took to accomplish
// pi = 4 * (1 – 1/3 + 1/5 – 1/7 + ...)
function* pi() {
let n = 1;
let series = 0;
while(true) {
next = 1/(n*2-1)