Sieve in JavaScript