data = {
let a = [];
let d = {
x: 0,
factorial: BigInt(1)
}
function stirlingApproximation(x) {
x = Number(x);
return Math.sqrt(2*Math.PI) * (x ** (x+0.5)) * Math.exp(-x) * (1+1/(12*x)+1/(288*x*x));
}
for (let x = 1 ; x <= range ; x++) {
d = {
x,
factorial: d.factorial * BigInt(x),
Stirling: stirlingApproximation(x),
};
d.repeatedFactorialApproximation = x < 3 ? x : Math.round(stirlingApproximation(d.factorial));
a.push(d);
}
return a;
}