login
a(n) = a(n-1) + a(n-1 minus the number of terms of the same parity as n so far).
0

%I #2 Mar 30 2012 17:30:31

%S 1,2,3,5,6,9,11,17,19,30,33,50,55,74,80,99,108,138,155,188,207,257,

%T 276,331,361,441,471,579,609,764,797,985,1018,1225,1275,1551,1601,

%U 1962,2017,2458,2532,2973,3053,3632,3731,4340,4448,5057,5195,5992

%N a(n) = a(n-1) + a(n-1 minus the number of terms of the same parity as n so far).

%e a(5) = a(4) + a(4 - the number of odd terms so far) = a(4) + a(4-3) = 5 + 1 = 6.

%t a[ 1 ] = 1; a[ 2 ] = 2; a[ n_ ] := a[ n ] = Block[ {e = 0}, Do[ If[ EvenQ[ a[ k ] ], e++ ], {k, 1, n - 1} ]; If[ EvenQ[ n ], a[ n - 1 ] + a[ n - 1 - e ], a[ n - 1 ] + a[ e ] ] ]; Table[ a[ n ], {n, 1, 15} ]

%Y Cf. A006336, A007604.

%K nonn

%O 1,2

%A _Robert G. Wilson v_, Apr 21 2001