next.js/examples/with-web-worker/utils/pi.ts
pi.ts10 lines262 B
// https://stackoverflow.com/a/39575124
export default function pi(n: number) {
  let v = 0;
  for (let 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
}
Quest for Codev2.0.0
/
SIGN IN