Javascript implementation of the approach
let limit = 1000000000 let MAX_PRIME = 2000000 let MAX = 1000000 let I_MAX = 50000 let mp = new Map ( ) ; let b = new Array ( MAX ) ; let p = new Array ( MAX ) ; let j = 0 ; let prime = new Array ( MAX_PRIME + 1 ) ;