Assume $f$ is partially recursive, say $f$ is $\varphi_e$ in an enumeration of the partial recursive functions. Then there exists a recursive enumeration of its domain, i.e., a set
$W_e$ such that
$$x \in W_e \Leftrightarrow \varphi_e(x)\downarrow$$
There are two possibilities how $W_e$ looks like.
Case 1: $W_e \neq \emptyset$. Since $W_e$ is recursively enumerable, let $W_{e,s}$ be the set $W_e$ at stage $s$ of its enumeration. $W_{e,s}$ is recursive (check it). Then let $m$ be the first element enumerated into $W_e$, i.e., $m$ is the element in the first $W_{e,s}$ for $s\rightarrow \infty$ such that $W_{e,s}\neq \emptyset$. Then the function
$$ f(s)=\left\{\begin{array}{ll} x & \text{ if } x\in W_{e,s}\setminus W_{e,s-1} \\ m & \text{otherwise}\end{array}\right. $$
is recursive and has range $W_e$ (check it).
Case 2: As was pointed out in the comments of another answer such $m$ must not exist, i.e. $W_e$ is empty. But then $W_e$ is a recursive set because its characteristic function is just the constant function.