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