# Series of sorts- Return 1 or 2 based on even or odd n

1. Mar 5, 2013

### connordurkin

I would like to create a series where for each term if n is odd the term =1 and if n is even, the term = 2. I.e.

$a_{n} = 1 if \ n \ is \ odd \ and \ a_{n} = 2 \ if \ n \ is \ even$

2. Mar 5, 2013

### connordurkin

Can anyone help me come up with some a_n such that this is true?

3. Mar 5, 2013

### Gackhammer

So what you are saying is ...

For input n = 1,2,3,4,5...

a_n = 1,2,1,2,1,2

There are a number of ways you can do this (click on Equations for Links )...

$2- n mod(2)$

$2-[sin^2(\frac{\pi n}{2})]$

Just a couple that I thought off in my head....
One is discrete, one is continuous

4. Mar 5, 2013

### pwsnafu

There is also $\frac{3+(-1)^n}{2}$