If $k$ is an integer, let $\mathrm{c}(k)$ denote the largest cube that is less than or equal to $k$. Find all positive integers $p$ for which the following sequence is bounded:

$$
a_{0}=p \quad \text { and } \quad a_{n+1}=3 a_{n}-2 c\left(a_{n}\right) \quad \text { for } n \geqslant 0
$$
Since $\mathrm{c}\left(a_{n}\right) \leqslant a_{n}$ for all $n \in \mathbb{N}, a_{n+1} \geqslant a_{n}$ with equality if and only if $\mathrm{c}\left(a_{n}\right)=a_{n}$. Hence the sequence is bounded if and only if it is eventually constant, which is if and only if $a_{n}$ is a perfect cube, for some $n \geqslant 0$. In particular, the sequence is bounded if $p$ is a perfect cube.

We now claim that, if $a_{n}$ is not a cube for some $n$, then neither is $a_{n+1}$. Indeed, if $a_{n}$ is not a cube, $q^{3}a_{n}>q^{3}$, so $q^{3}<a_{n+1}<(q+3)^{3}$. It follows that the only possible values of $a_{n+1}$ are $(q+1)^{3}$ and $(q+2)^{3}$. However, in both of these cases,

$$
\begin{aligned}
& 3 a_{n}-2 q^{3}=a_{n+1}=(q+1)^{3} \Longleftrightarrow 3 a_{n}=3\left(q^{3}+q^{2}+q\right)+1 \\
& 3 a_{n}-2 q^{3}=a_{n+1}=(q+2)^{3} \Longleftrightarrow 3 a_{n}=3\left(q^{3}+2 q^{2}+4 q\right)+8
\end{aligned}
$$

a contradiction modulo 3. This proves that, if $a_{n}$ is not a cube, then neither is $a_{n+1}$. Hence, if $p$ is not a perfect cube, $a_{n}$ is not a cube for any $n \in \mathbb{N}$, and the sequence is not bounded. We conclude that the sequence is bounded if and only if $p$ is a perfect cube.