Need a hint/advice as to how to factor very large numbers in JavaScript
My task is to produce an array containing all the prime numbers up to a 12-digit number. I tried to emulate the Sieve of Eratosthenes by first making a function enumerate that produces an array containing every integer from 2 to num : var enumerate = function(num) { array = []; for (var i = 2; i <= num; i++) { array.push(i); } return array; }; Then I made a function leaveOnlyPrimes which loops through and removes multiples of every array member up to 1/2 max from the array (this does not end up being every integer because the array become smaller with every iteration): var leaveOnlyPrimes =