How to add a condition in the sum function in sage
I want to implement the following sum ∑nj=0ajxj under the following conditions the coefficient aj=j if j is even, or j+1 otherwise. My problem is how to include these cases in the sum function in sage. Normally the command is sum(a_j*x^j,j,1,n) but how to distinguish between the parity of j ?