As the title shows, I need help approaching a solution for recurrence relation:
$f(n) = f(\lfloor\sqrt n\rfloor) + 1$ if $n\ge3$
with initial values $f(1) = 1$, $f(2) = 1$
I am particularly confused by the square root. All I'm trying to get is $f(n)$ in just terms of $n$ without the recursion.
For every positive $n$ there is exactly one nonnegative integer $a$ with $$a^2\le n<(a+1)^2$$
We have $\lfloor \sqrt{n} \rfloor=a$. Hence, the function $f$ is constant between squares, then resets to a new value. That is, $$f(2)=f(3)=2$$ $$f(4)=f(5)=\cdots=f(8)=f(2)+1=3$$ $$f(9)=f(10)=\cdots=f(15)=f(3)+1=3$$ $$f(16)=f(17)=\cdots=f(24)=f(4)+1=4$$