Public
Edited
Jun 23, 2023
Insert cell
Insert cell
function gcd(a, b) {
let t;
while (b !== 0) {
t = b;
b = a % b;
a = t;
}
return a;
}
Insert cell
function* alternating() {
let n = 4;
let order = 24n;
while (true) {
yield { n, order };
n++;
order *= BigInt(n);
}
}
Insert cell
[...takeWhile(suzuki_B2(), (n) => n.order < 10n ** 53n)]
Insert cell
function suzuki_B2() {
return mapIter(naturals(1), (n) => {
let q = BigInt(2 ** (2 * n + 1));
return {
q,
order: q ** 2n * (q ** 2n + 1n) * (q - 1n)
};
});
}
Insert cell
function ree_F4() {
return mapIter(naturals(1), (n) => {
let q = BigInt(2 ** (2 * n + 1));
return {
q,
order:
q ** 12n * (q ** 6n + 1n) * (q ** 4n - 1n) * (q ** 3n + 1n) * (q - 1n)
};
});
}
Insert cell
function ree_G2() {
return mapIter(naturals(1), (n) => {
let q = BigInt(3 ** (2 * n + 1));
return {
q,
order: q ** 3n * (q ** 3n + 1n) * (q - 1n)
};
});
}
Insert cell
function* powers(n) {
n = BigInt(n);
let total = n;
while (true) {
yield total;
total *= n;
}
}
Insert cell
function* naturals(start) {
let n = start;
while (true) {
yield n;
n++;
}
}
Insert cell
function* mapIter(generator, predicate) {
for (let item of generator) {
yield predicate(item);
}
}
Insert cell
function* takeWhile(generator, pred) {
while (true) {
const next = generator.next().value;
if (!pred(next)) {
break;
}
yield next;
}
}
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