Create a boolean array " isPrime [ 0 . . N ] " and initialize all entries it as true . A value in isPrime [ i ] will finally be false if i is not a prime , else true .
let isPrime = new Array ( ) ; for ( let i = 0 ; i < Large + 1 ; i ++ ) { isPrime . push ( [ ] ) } isPrime . fill ( true ) ; for ( let p = 2 ; p * p <= Large ; p ++ ) {