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: 
Here is a way to arrive at an answer using generating functions. Let the desired sequence be $\{a\_n\}$ for $n\geq 1$ ($a\_0=0$). Note that
$$
\sum\_{n=0}^\infty a\_nx^n=\sum\_{n=0}^\infty \frac{x^{2n+1}}{1-x}=\frac{x}{(1-x)(1-x^2)}=\frac{-1}{4(1+x)}-\frac{1}{4(1-x)}+\frac{1}{2(1-x)^2}\tag{1}
$$
by partial fractions. Equation (1) makes sense as an identity of formal power series or for $|x|<1$. Then using the geometric series we obtain
$$
\sum\_{n=0}^\infty a\_nx^n=\sum\_{n=0}^\infty
\left(\frac{(-1)^{n+1}-1+2(n+1)}{4}\right)
x^n
=\sum\_{n=1}^\infty
\left(\frac{(-1)^{n+1}+2n+1}{4}\right)
x^n.\tag{2}
$$
Hence
$$
a\_n=\frac{(-1)^{n+1}+2n+1}{4};\quad {(n\geq1)}.\tag{3}
$$
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.