Published
Edited
Mar 8, 2019
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
data = {
let x = Math.max(1, Math.floor(number)) || 1;
let i = 0;
let q;
let n;
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;
n=1;
x=q;
//* Coalesce repeated factors
while ((q = x / p) > 1 && q === Math.floor(q)) {
n++;
x=q;
}
// */
nodes.push(p+"**"+n);
nodes.push(x);
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

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