Published
Edited
Jun 18, 2018
4 stars
Insert cell
Insert cell
fact = x => {
let acc = 1n;
while (x > 1n) {
acc = acc * --x;
}
return acc;
}
Insert cell
function sumDigits(x) {
let str = x.toString();
let sum = 0;
for (let char of str) {
sum += +char;
}
return sum;
}
Insert cell
Insert cell
factorial = fact(100n)
Insert cell
Insert cell
sumDigits(factorial)
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