Merge LibSi(e)ve with JS++

This commit is contained in:
The Ghost of FOSS' Past 2024-12-06 20:22:40 -06:00
parent 6da0f0e6b6
commit 8b18d5d8bd

24
jspp.js
View file

@ -26,6 +26,30 @@ class JSPlusPlus {
return t
}
isPrime = num => {
for(let i = 2, s = Math.sqrt(num); i <= s; i++) {
if(num % i === 0) return false;
}
return num > 1;
}
sieve(siveTo) {
let primes = []
siveTo = Number(siveTo)
for (var i = 1; i < siveTo; i++) {
if (isPrime(i)) {
primes.push(i)
}
}
if (isPrime(siveTo)) {
primes.push(siveTo)
}
return primes
}
async asyncSleep(ms) {
await new Promise(r => setTimeout(r, ms));
}