text: Main logic of Sundaram . Mark all numbers of the form i + j + 2 ij as true where 1 <= i <= j
code: for ( let i = 1 ; i <= nNew ; i ++ ) for ( let j = i ; ( i + j + 2 * i * j ) <= nNew ; j ++ ) marked [ i + j + 2 * i * j ] = true ;