Public
Edited
Nov 15, 2023
Insert cell
# Nat Notation Primes
Insert cell
primeGaps
X
index
Y
gap
Color
Size
p
Facet X
Facet Y
Mark
dot
Type Chart, then Shift-Enter. Ctrl-space for more options.

Insert cell
primeGaps = smallPrimes.map((p, i) => {
let gap = smallPrimes[i + 1] - p;
return {
index: i + 1,
gap,
gapNormed: gap / p,
p
};
})
Insert cell
// function factorize(n) {
// let result = {};
// for (let p of smallPrimes) {
// console.log("testing ", p);
// while (n % p === 0) {
// n /= p;
// console.log("n = ", n);
// if (!result[p]) {
// result[p] = 0;
// }
// result[p]++;
// }
// if (n === 1) {
// return result;
// }
// }
// return result;
// }
Insert cell
smallPrimes = [...takeWhile(primes(), (p) => p < 1000)]
Insert cell
function* takeWhile(gen, pred) {
for (let item of gen) {
if (pred(item)) {
yield item;
} else {
return;
}
}
}
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