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}
$$
$$
f(n)=\left\{ 
\begin{array}{c}
n/2, \: n \: is \: even \\ 
(n+1)/2, \: n \: is \: odd \\ 
\end{array}
\right. 
$$