Bad PI Approximation
let inside = 0;
let precision = 1e6;
for (let i = 0; i < precision; i++){
const xp = 0.5 - Math.random();
const yp = 0.5 - Math.random();
if (Math.sqrt(xp * xp + yp * yp) < 0.5) {
inside++;
}
}
console.log(inside / precision * 4);
This is a funny one, someone described this to me once and I coded it up over on actionsnippet.