You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
function primeFactorsTo(max)
|
|
{
|
|
var store = [], i, j, primes = [];
|
|
for (i = 2; i <= max; ++i)
|
|
{
|
|
if (!store [i])
|
|
{
|
|
primes.push(i);
|
|
for (j = i << 1; j <= max; j += i)
|
|
{
|
|
store[j] = true;
|
|
}
|
|
}
|
|
}
|
|
return primes;
|
|
}
|
|
|
|
console.log(primeFactorsTo(5));
|
|
|
|
console.log(primeFactorsTo(15));
|