# Functional form

Is there an analytic form of a function that satisfies the following:

\begin{align*} f:\mathbb N &\to \mathbb N\\ 1&\mapsto 1\\ 2&\mapsto 2\\ 3&\mapsto 2\\ 4&\mapsto 3\\ 5&\mapsto 3\\ 6&\mapsto 3\\ 7&\mapsto 4\\ &\vdots \end{align*}

-
If you have the $n$th triangular number $T_n$ that is the smallest triangular number equal to or larger than $m$, note that $f(m)=n$. – Meow Apr 11 '13 at 16:27

Assuming $f(n)=4$ for $7 \le n \le 10$ (so there are $4 \ \ 4$'s and so on) you are finding the minimum $m$ such that $\frac 12 m(m+1) \ge n$, which is a triangular number. To get an explicit formula, we can invert $\frac 12 m(m+1) = n$ by saying $m^2+m-2n=0, m=\frac 12(-1+\sqrt{1+8n})$ and rounding up: $$m=\left\lceil\frac 12\bigg(-1+\sqrt{1+8n}\bigg)\right\rceil$$