{
let dim = 1000;
let pow = 9;
let factors = primeFactors(2 ** pow);
let ratio = 1 / Math.sqrt(2);
let getPos = (n) => {
let r = dim * ratio ** (factors[n].length - 1);
let theta = ((n / 2 ** pow) * Math.PI) / 2;
let x = -r * Math.cos(-theta);
let y = -r * Math.sin(-theta);
return [x, y];
};
let margin = 10;
return svg`<svg width="${dim}" height="${dim}" viewbox="${-dim} ${0} ${dim} ${dim}">
${_.range(pow - 1).map((i) => {
return svg`<circle r="${
dim * ratio ** i
}" stroke="lightgrey" fill="none"/>`;
})}
${_.range(2, 2 ** pow)
.filter((i) => factors[i].length > 1)
.flatMap((i) => {
let [x1, y1] = getPos(i);
return _.uniq(factors[i]).map((f) => {
let q = i / f;
let [x2, y2] = getPos(q);
let path = `M ${x1} ${y1} L ${x2} ${y2}`;
let color = d3.interpolateRainbow(Math.log2(f) / pow);
return svg`<path d="${path}" stroke="${color}" fill="none" opacity=".5"/>`;
});
})}
${_.range(2, 2 ** pow).map((i) => {
let [x, y] = getPos(i);
return svg`<circle r="2" cx="${x}" cy="${y}" fill="black"/>`;
})}
</svg>`;
}