## - Problem 2

Let $N_{0}$ and $Z$ be the set of all non-negative integers and the set of all integers, respectively. Let $f: N_{0} \rightarrow Z$ be the function that associates to each element $n$ of $N_{0}$ the integer $f(n)$ defined by

$$
f(n)=-f\left(\left\lfloor\frac{n}{3}\right\rfloor\right)-3\left\{\frac{n}{3}\right\}
$$

where $\lfloor x\rfloor$ is the integer part of the real number $x$ and $\{x\}=x-\lfloor x\rfloor$ is its fractional part. Determine the smallest integer $n$ such that $f(n)=2010$.

NOTE: The integer part of a real number $x$, denoted by $\lfloor x\rfloor$, is the greatest integer that does not exceed $x$. Thus $\lfloor 1.98\rfloor=1, \lfloor-2.001\rfloor=-3, \lfloor 7\pi-8.03\rfloor=13$.
## Solution:

It is easily proved by induction that, if $n=\left(\overline{a_{k} a_{k-1} \ldots a_{0}}\right)_{3}$, then

$$
f(n)=\sum_{\substack{j=0 \\ j \text { odd }}}^{k} a_{j}-\sum_{\substack{j=0 \\ j \text { even }}}^{k} a_{j}
$$

Indeed, $f(0)=0, f(1)=-1, f(2)=-2$.

Suppose that, for all $n$ less than $3 t, f(n)=\sum_{\substack{j=0 \\ j \text { odd }}}^{k} a_{j}-\sum_{\substack{j=0 \\ j \text { even }}}^{k} a_{j}$. Then, if $t=\left(\overline{b_{k} \ldots b_{0}}\right)_{3}, 3 t=\left(\overline{b_{k} \ldots b_{0} 0}\right)_{3}, 3 t+1=\left(\overline{b_{k} \ldots b_{0} 1}\right)_{3}, 3 t+2=\left(\overline{b_{k} \ldots b_{0} 2}\right)_{3}$. Therefore, since $f(3 t)=-f(t), f(3 t+1)=-f(t)-1, f(3 t+2)=-f(t)-2$, the property remains true for all integers $n$ less than $3 t+2$.

Thus, for all $n=\left(\overline{a_{k} a_{k-1} \ldots a_{0}}\right)_{3}, f(n)=\sum_{\substack{j=0 \\ j \text { odd }}}^{k} a_{j}-\sum_{\substack{j=0 \\ j \text { even }}}^{k} a_{j}$.

In this way, the smallest $n=(\overline{2020 \ldots 20})_{3}$, such that $f(n)=2010$, is obtained. This number contains 1005 twos; its value in decimal is:

$$
3 \cdot \frac{3^{2010}-1}{4}
$$