Function to generate a fixed number of even or odd terms . The size of r decides whether numbers to be generated even or odd .
static List < long > gen ( long n , List < long > r ) { long a = r [ r . Count - 1 ] ; a ++ ; for ( int i = 1 ; i <= n ; a += 2 , i ++ ) r . Add ( a ) ; return r ; }