In how many ways can a number be factorized over the field $\mathbb{Z}_p$ into two numbers? For example, over the field $\mathbb{Z}_5$, we can factor number 4 into two numbers in three different ways, i.e. 4=4$\times$1, 4=2$\times$2, and 4=3$\times$3. I am looking for a general formula of the form $f_{p}(n)$ that gives the number of different factorizations of a given number $n\in\mathbb{Z}_p$ into two numbers over the field $\mathbb{Z}_p$.
In the above example, $f_{5}(4)$=3. 
Thank you very much

Let $p>2$ be an odd prime. Then
$$f_p(0)=p,$$
$$f_p(n)=\frac{p-1}{2}\textrm{ if }n\neq0\textrm{ is not a square mod }p,$$
$$f_p(n)=\frac{p+1}{2}\textrm{ if }n\neq0\textrm{ is a square mod }p,$$
If $n=0$ then there are $p$ ways to factorise it ($m\times 0=0$).
Now suppose $n\neq 0$ and consider the elements $a^{-1}n\in \mathbb{Z}_p$ for any $a\in\mathbb{Z}_p\backslash\{0\}$.  These each give a factorisation of $n$, so the question becomes how many distinct sets of the form $\{ a,a^{-1}n\}$ are there, as $a$ ranges over $\mathbb{Z}_p\backslash\{0\}$. 
Suppose first that this set has size 2, so that $a\neq a^{-1}n$. Then the set is uniquely determined by the minimal element. If all sets have size 2, so that $n$ is not a quadratic residue, these cover all of the possibilities, so $f_p(n)=(p-1)/2$. 
If $a$ is a quadratic residue, say $n=a^2$, then we must include the sets $\{a\}$ and $\{-a\}$ as well. Hence $f_p(n)=(p-3)/2+2=(p+1)/2$.
