Half-Baked Pi

PI is a Strange Loop

(function aPieceOfPi(numerator, denominator) {
  const n = numerator;
  const d = denominator;
  try {
    return n / d * n / (d + 2) * aPieceOfPi(n + 2, d + 2);
  }
  catch(stackoverflow) {
    console.log(stackoverflow.message);
    return 1;
  }
})(2, 1)

ROBOT:I'll explain while...

(function anotherPieceOfPi(numerator, denominator, iterations) {
  let n = numerator;
  let d = denominator;
  let piece = 1;
  while (iterations-- > 0) {
    piece = piece * n / d * n / (d + 2);
    n += 2;
    d += 2;
  }
  return piece;
})(2, 1, 100000000)