utils/tune-hash.js
function getPrimes(limit) {
    var sieve = new Array(limit);
    var n, j, k;
    var last = Math.floor(Math.sqrt(limit));
    for (n=2; n < limit; n++) {
        sieve[n] = true;
    }
    for (n=2; n <= last;) {
        for (j= n+n; j < limit; j += n) {
            sieve[j] = false;
        }
        for (j=1; j < last; j++) {
            k = n+j;
            if (sieve[k]) {
                n = k;
                break;
            }
        }
    }
    var primes = [];
    for (n=2; n < limit; n++) {
        if (sieve[n]) {
            primes.push(n);
        }
    }
    return primes;
}
function getPrimes(limit) {
    var sieve = new Array(limit);
    var n, j, k;
    var last = Math.floor(Math.sqrt(limit));
    for (n=2; n < limit; n++) {
        sieve[n] = true;
    }
    for (n=2; n <= last;) {
        for (j= n+n; j < limit; j += n) {
            sieve[j] = false;
        }
        for (j=1; j < last; j++) {
            k = n+j;
            if (sieve[k]) {
                n = k;
                break;
            }
        }
    }
    var primes = [];
    for (n=2; n < limit; n++) {
        if (sieve[n]) {
            primes.push(n);
        }
    }
    return primes;
}
function getPrimes ( limit ) { var sieve = new Array ( limit ) ; var n , j , k ; var last = Math . floor ( Math . sqrt ( limit ) ) ; for ( n = 2 ; n < limit ; n ++ ) { sieve [ n ] = true ; } for ( n = 2 ; n <= last ; ) { for ( j = n + n ; j < limit ; j += n ) { sieve [ j ] = false ; } for ( j = 1 ; j < last ; j ++ ) { k = n + j ; if ( sieve [ k ] ) { n = k ; break ; } } } var primes = [ ] ; for ( n = 2 ; n < limit ; n ++ ) { if ( sieve [ n ] ) { primes . push ( n ) ; } } return primes ; }
sieve of Eratosthenes to get prime numbers.

@param limit
sieve of Eratosthenes to get prime numbers .