What algorithm / formula uses the code below?
public static int piDigit(int n) { if (n < 0) return -1; n -= 1; double x = 4 * piTerm(1, n) - 2 * piTerm(4, n) - piTerm(5, n) - piTerm(6, n); x = x - Math.floor(x); return (int)(x * 16); } private static double piTerm(int j, int n) {
This code has already been written for us in our set of problems. I canβt find which algorithm / formula it uses, and I'm interested. I suspect this is a simple algorithm, but I cannot find the formula online based solely on this part of the code.
source share