Question: I am trying to solve a programming problem where i encounter this pattern 1 1 2 2 3 3 4 4 . What is the formula for computing it for Nth term ?

Answer: 
Formula $$f(n) = \dfrac{2n+1+(-1)^{n+1}}{4}, \qquad \quad n = 1,2,3,\ldots$$ works too.

Or anything like this:
$$f(n) = \dfrac{2n+1-\cos(\pi n)}{4}, \qquad \quad n=1,2,3,\ldots .$$
Well? What answer do you *want*?

$a\_N \approx \frac N2$ but the exact value depends on whether $N$ is even or odd. 

The must obvious "binary" function that has two values depending on if the input is even or odd is $(-1)^N$ which is $1$ if $N$ is even and $-1$ if $N$ is odd.

So you have if $N = 2n-1; 2n$ if $N$ is odd; even$ then $a\_N = n = \frac N2; \frac {N+1}2$ if $N$ is even;odd.

Or $a\_N = \frac N2 + b\_N$ where $b\_N = 0$ if $N$ is even or $b\_N = \frac 12$ if $N$ is odd.

To solve for $b\_N$ note:

$(-1)^N = 1; -1$ if $N$ is even; odd.

$(-1)^N - 1 = 0; -2$

$\frac {(-1)^N -1}4 = 0, -\frac 12$.

$-\frac{(-1)^N -1}4 = 0; \frac 12$

So $a\_N = \frac N2 - \frac {(-1)^N -1}4$ is a solution if you *must* have a single line purely mathematical expression.

But *surely* if you are programming you are allowed to use conditional IF clauses and define a function based on whether the input is even or not.

So simply "if $N$ % $2== 0$ return $\frac N2$; else return $\frac {N+1}2$;" will do.