$f$ is a function from the set of positive integers to the set of all integers that satisfies the following. $\cdot$ $f(1)=1, f(2)=-1$ $\cdot$ $f(n)+f(n+1)+f(n+2)=f(\left\lfloor\frac{n+2}{3}\right\rfloor)$ Find the number of positive integers $k$ not exceeding $1000$ such that $f(3)+f(6)+\cdots+f(3k-3)+f(3k)=5$.
Problem
Source: 2024 KJMO P8
Tags: function, algebra
09.11.2024 16:11
RL_parkgong_0106 wrote: $f$ is a function from the set of positive integers to the set of all integers that satisfies the following. $\cdot$ $f(1)=1, f(2)=-1$ $\cdot$ $f(n)+f(n+1)+f(n+2)=f(\left\lfloor\frac{n+2}{3}\right\rfloor)$ Find the number of positive integers $k$ not exceeding $1000$ such that $f(3)+f(6)+\cdots+f(3k-3)+f(3k)=5$. 1) $f(3n)=f(n)$; $f(3n+1)=1$ and $f(3n+2)=-1$
Let $g(n)=\sum_{i=1}^nf(i)$ (so that we are looking for $g(k)=5$) We easily get $g(3k)=g(3k+2)=g(k)$ and $g(3k+1)=g(k)+1$ And so $g(n)$ is the number if digits $1$ in the representation of $n$ in base $3$ And so we are looking for the number of positive integers $k\le 1000$ such that $k$ contains exactly $5$ digits $1$ in its base $3$ representation Since $k\le 1000=\overline{1101001}_3$ : From $\overline 0_3$ to $\overline{0222222}_3$, we have $2^1\binom 65=12$ such numbers From $\overline{1000000}_3$ to $\overline{1022222}_3$, we have $2^1\binom 54=10$ such numbers From $\overline{1100000}_3$ to $\overline{1100222}_3$, we have exactly one such number From $\overline{1101000}_3$ to $\overline{1101001}_3$, we have none And so $\boxed{23\text{ such numbers }k}$