What is known as the Bailey-Borwein-Plouffe algorithm is a digit-extraction algorithm for calculating the digits of pi discovered by Simon Plouffe in 1995. Plouffe's amazing formula is given by

for (var i=0; i<=n; i++){
res += ( 4/(8*i+1) - 2/(8*i+4) - 1/(8*i+5) - 1/(8*i+6) ) * Math.pow(1/16,i);
}
Insert a number: n > 0