Question: I am looking for a formula which will tell me how many times I must divide a number $(n)$ by $2$ until its value is less than or equal to $1$.

For example, for $n=30$ $(30,15,7.5,3.25,1.75,0.875)$ would yield $5$ (number of times divided by $2$).

How can I express this as a formula?

Answer: 
If you do not have the ceil function at your disposal, you can use the following formula :
$$m=\begin{cases}\left\lfloor\dfrac{\ln n}{\ln2}\right\rfloor+1\quad\text{ if }\;n\;\text{ is not a power of }2\\\left\lfloor\dfrac{\ln n}{\ln2}\right\rfloor\qquad\;\text{ if }\;n\;\text{ is a power of }2\end{cases}$$

which does not require $\;\log\_2x\;$ function but just the natural logarithm.

In other words :

if $\;\left\lfloor\dfrac{\ln n}{\ln 2}\right\rfloor=\dfrac{\ln n}{\ln 2}\;,\;$ then

$m=\left\lfloor\dfrac{\ln n}{\ln 2}\right\rfloor\quad$ otherwise $\quad m=\left\lfloor\dfrac{\ln n}{\ln 2}\right\rfloor+1\;.$

The symbol $\lfloor x\rfloor$ is the floor function and means "the greatest integer less than or equal to $x$". Programming languages have the floor function.
The formula is $\lceil\log\_2 n\rceil$, the symbol $\lceil x\rceil$ meaning "the smallest integer greater or equal to $x$". (Programming languages often have a `ceil` function.)

This is because, if $m=\lceil\log\_2n\rceil$, then $m-1\lt\log\_2n\le m$, i.e. $2^{m-1}\lt n\le 2^m$ i.e. $\frac{n}{2^m}\le 1\lt \frac{n}{2^{m-1}}$ which means that $m-1$ halvings isn't enough to bring $n$ to $1$ (or under), but $m$ halvings *is*.

**Update**: If your platform does not support $\lceil x\rceil$ but it supports $\lfloor x\rfloor$, with the meaning "the largest integer less or equal than $x$" (often known as the `floor` function), then recall that $\lceil x\rceil=-\lfloor-x\rfloor$, i.e. the formula becomes $-\lfloor-\log\_2 n\rfloor$. Make sure that your implementation of $\lfloor x\rfloor$ works correctly for the negative numbers, e.g. $\lfloor -0.5\rfloor=-1$.