Finding prime number using sieve of Eratosthenes . Reusing same array as result of above computations in v .
arr = Array ( n + 1 ) . fill ( false ) ; for ( var p = 2 ; p * p < n ; p ++ ) { if ( arr [ p ] == false ) for ( var i = p * 2 ; i < n ; i += p ) arr [ i ] = true ; }