Proving a certain primitive recursive function exists
The function $g$ interprets $k$ as two inputs $k_1,k_2$. It runs $f(n,k_1)$ for $k_2$ steps, returns whatever $f$ does if $f$ halts, and returns $0$ otherwise.