Published
Edited
Jan 22, 2019
1 star
Insert cell
Insert cell
M_exponents = [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951, 30402457, 32582657, 37156667, 42643801, 43112609, 57885161, 74207281, 77232917, 82589933]
Insert cell
Insert cell
n = {
for (let i=0; i<30; i++) {
await Promises.delay(2000)
yield i
}
}
Insert cell
Insert cell
Mersenne = {
let p = M_exponents[n]
return 2n**BigInt(p)-1n
}
Insert cell
Insert cell
digits = String(Mersenne).split('')
Insert cell
Insert cell
Number(Mersenne)
Insert cell
Insert cell
function isPrime(p) {
let i = 2n
while (Number(i) < Math.sqrt(Number(p))) {
if (p % i === 0n) return {'is prime?': false, 'smallest factor': i};
if (i == 2n) i=3n
if (i == 3n) i=5n
if (i % 6n == 1) i=i+4n
if (i % 6n == 5) i=i+2n
}
return {'is prime?': true};
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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