Value of a Recursively Defined Base-3 Function
Number Theory · 25th PMO Qualifying Stage
A function $f:\mathbb{N}\cup\{0\}\to\mathbb{N}\cup\{0\}$ is defined by $f(0)=0$ and $$f(n)=1+f\left(n-3^{\lfloor\log_3 n\rfloor}\right)$$for all integers $n\geq1$. Find the value of $f(10^4)$.