function getPi(){
    function getRand(maxRand){
        return Math.floor(Math.random()*maxRand);
    }
    function gcd(a,b) {
        if (!b) return a;
        else return gcd(b,a%b);
    };
    let coPrimes = 0;
    const iterations = 10000000;
    const maxRand = 10000000;
    for (var i = 0; i < iterations; i++) {
        const n1 = getRand(maxRand);
        const n2 = getRand(maxRand);
        if(gcd(n1,n2) === 1) coPrimes++;
    }
    const proportion = coPrimes/iterations;
    const result = Math.sqrt(6/proportion);
    console.log(result);
    return result;
}

// details: https://www.youtube.com/watch?v=RZBhSi_PwHU