Public
Edited
Feb 19, 2024
Paused
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
result = factorial(Q)
Insert cell
Insert cell
factorial(10)
Insert cell
factorial = {
let stash = [1n, 1n];

return function(n) {
for (let i = stash.length; i <= n; i++) {
stash.push(BigInt(i) * stash[i - 1]);
}

return {
n,
sequence: stash,
tail: stash[n] + ""
};
}
}
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more