@nexys/math-ts
Version:
[](https://www.npmjs.com/package/@nexys/math-ts) [](https://travis-ci.com/github/Nexysweb/math-ts) [ • 540 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPrime = (i, p) => {
if (p.length > 0) {
if (i % p[0] === 0 && i !== p[0]) {
return false;
}
const d = p.slice(1, p.length);
return exports.isPrime(i, d);
}
return true;
};
exports.prime = (n) => {
const p = [3, 5];
let i = 7;
while (i < n) {
if (i % 10 !== 5 && exports.isPrime(i, p)) {
p.push(i);
}
i = i + 2;
}
return [1, 2].concat(p);
};