Answer
See the detailed answer below.
Work Step by Step
We know that
$$\phi=\tan^{-1}\left[\dfrac{X_L-X_C}{R}\right]$$
Let's draw than in a right triangle, as shown below.
Now we can see that
$$\cos\phi=\dfrac{R}{H}\tag 1$$
We can see, from the figure below, that the hypotenuse of the triangle is
$$H=\sqrt{(X_L-X_C)^2+R^2}=Z$$
where this is the impedance $Z$, so $H=Z$.
Plug that into (1),
$$\boxed{\cos\phi=\dfrac{R}{Z} }$$