Is there a formula for finding the number of divisors of $n$ without factorize it? I know that the number of divisors of $n$, $d(n)$ is $$d(n) = \Pi_{i=1}^k (a_i+1)$$ where each $a_i$ is the exponent of each prime factor of $n$. My question is: can I calculate $d(n)$ without know the factorization of $n$? something like a closed form that depends only on $n$?
 A: Yes there is a formula, but it is sort of a mess:
$$d(n)=\sum_{k=1}^{n}\left\lfloor \exp\left(k\left\lfloor\frac{n}{k}\right\rfloor-n\right) \right\rfloor.\tag1$$
Below is a proof of $(1)$.
Define the functions
$$\begin{align}
a(x)&=\lfloor\exp(-x)\rfloor,\\
b(n,k)&=n-k\left\lfloor\frac{n}{k}\right\rfloor,\\
i(n,k)&=a(b(n,k)).
\end{align}$$
First, notice that $a(0)=1$, and $a(x)=0$ for all $x\ge1$.
Next, notice that if $n=mk$ for some $m\in\Bbb N$, then $$b(n,k)=b(mk,k)=mk-k\lfloor m\rfloor=mk-mk=0.$$
On the other hand, if $n=mk+j$ for $m,j\in\Bbb N$, $1\le j<k$, we have
$$\begin{align}
b(n,k)&=b(mk+j,k)\\
&=mk+j-k\left\lfloor\frac{mk+j}{k}\right\rfloor\\
&=mk+j-k\left\lfloor m+\frac{j}{k}\right\rfloor\\
&=mk+j-mk\\
b(n,k)&=j\\
\Rightarrow b(n,k)&\ge1.
\end{align}$$
So, if $n=mk$, then $$i(n,k)=a(b(n,k))=a(0)=1,$$
and if $n=mk+j$, then $$i(n,k)=a(b(n,k))=a(j)=0,$$
so we have
$$i(n,k)=
\begin{cases}
1, & \text{if } k|n\\
0, & \text{otherwise}. 
\end{cases}
$$
Then if we sum $i(n,k)$ over $1\le k\le n$ we get $+1$ for every divisor of $n$ and $+0$ for all non-divisors. Thus
$$d(n)=\sum_{k=1}^{n}i(n,k).$$
