Published
Edited
Mar 20, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = {
let x = Math.max(1, Math.floor(number)) || 1;
let i = 0;
let q;
const nodes = [x];
const links = [];
yield {nodes, links};
for (const p of primes()) {
if (!(p * p <= x)) break;
while ((q = x / p) > 1 && q === Math.floor(q)) {
const i = nodes.length - 1;
nodes.push(p, x = q);
links.push([i, i + 1], [i, i + 2]);
yield {p, nodes, links};
}
if (++i % 1000 === 0) {
yield {p, nodes, links};
}
}
}
Insert cell
dot = require("@observablehq/graphviz@0.2")
Insert cell
import {primes} from "@mourner/fast-prime-generator"
Insert cell
import {rasterize} from "@mbostock/saving-svg"
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