Function to generate a fixed number of even or odd terms . The size of r decides whether numbers to be generated even or odd .
function gen ( n , r ) { var a = r [ r . length - 1 ] ; a ++ ; for ( var i = 1 ; i <= n ; a += 2 , i ++ ) r . push ( a ) ; return r ; }