Show that the function $$f(x)=\begin{cases}1,&\text{if $x$ is prime;}\\\0,&\text{otherwise}\end{cases}$$ is primitive recursive. Then show that given any primitive recursive function $f:\mathbb N\to\mathbb N$, the function $g:\mathbb N\to\mathbb N$ such that $g(x)=\sum_{y=1}^xf(x)$ is also primitive recursive. Then adapt this to prove what you want.
Mariano Suárez-Álvarez
- 47.3k
- 14
- 147
- 264