Why is this function computable
You can check that P halts iff $x = ty$ for some integer $t \geq 1$. Hence $g(x,y,z)$ is just the following function:
$$
g(x,y,z) = \begin{cases} 1 &amp; \text{ if $x = ty$ for some integer $t \geq 1$}, \\ 0 &amp; \text{ otherwise.} \end{cases}
$$
Given integers $x,y$, it is not hard to check whether $x = ty$ for some integer $t \geq 1$. Hence $g$ is computable (even in polynomial time!).