Published
Edited
Apr 17, 2020
1 star
Insert cell
Insert cell
Insert cell
program = function collatzSequece(n) {
let sequence = [n];
if (n <= 0) {
return [];
}
while (n !== 1) {
if(n % 2 === 0) {
n = n / 2;
} else {
n= 3 * n + 1;
}
sequence.push(n)
}
return sequence;
}
Insert cell
Insert cell
Insert cell
dot`${Styx.exportAsDot(parsed.flowGraph)}`
Insert cell
es_parsed = Esprima.parse(program.toString());
Insert cell
parsed = Styx.parse(es_parsed);
Insert cell
Insert cell
Insert cell
Insert cell
Styx = import("https://cdn.pika.dev/styx")
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