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