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$ and $a_{n+1} = 3a_n-2\mathrm{c}(a_n)$ for $n \geqslant 0$.
Well $a_{n+1}=3a_n-\mathrm{c}(a_n)\ge 3a_n-2a_n=a_n$ since $a_n\ge\mathrm{c}(a_n)$. If the sequence is bounded then $a_{n+1}=a_n$ implying $\mathrm{c}(a_n)=a_n$ i.e. when $a_n$ is a perfect cube.
Suppose there exists a perfect cube in the sequence, say $a_{k}$ is a perfect cube. Then $m^3=a_k=3a_{k-1}-\mathrm2{c}(a_{k-1})$. For the sake of brevity allow $\mathrm{c}(a_{k-1})=b^3$. So $m^3+2b^3=3a_{k-1}$. This means $m+2b=0\pmod{3}$ i.e. $m=b\pmod{3}$ so $m=b+3l$ for $l$ a non-negative integer.
Suppose $l\ge 1$.
Then $3a_{k-1}=2b^3+m^3=2b^3+ (b+3l)^3=3b^3+9b^2l+27bl^2+27l^3$ i.e. $a_{k-1}=b^3+3b^2l+9bl^2+9l^3> b^3+3b^2+3b+1=(b+1)^3$, implying that $\mathrm{c}(a_{k-1})\ge (b+1)^3>b^3$ contradiction. So $l=0$. Then $m=b$, meaning the inequality $m^3\ge a_{k-1}\ge b^3$ is the same as saying $m^3=b^3=a_{k-1}$.
Hence $a_{k-1}$ is a cube. So have proved that if $a_{k}$ is a cube, so is $a_{k-1}$. So if the sequence is bounded, then $a_n$ is a perfect cube for some $n$, meaning $a_{n-1}$ is perfect cube etc until we reach $a_0=p$. So we require $p$ to be a perfect cube.