3

$f(n)=f(n-\sqrt{n})$

I believe $f(n)\in O(\sqrt{n})$

However I cannot seem to prove it, my intuition comes from the fact that we can remove $\sqrt{n}$ exactly $\sqrt{n}$ times, but if $n$ shrinks then does anything change?

D.W.
  • 159,275
  • 20
  • 227
  • 470
shane
  • 195
  • 1
  • 6
  • Try proving it. Have you tried using proof by induction to prove that your conjecture is true? You can also look at our reference question on this topic -- see especially the guess & prove answer. 2. Are you sure you have your recurrence correct? It's not $f(n) = f(n-\sqrt{n}) + 1$ or something like that? As it stands a solution to your recurrence is $f(n)=1$ for all $n$.
  • – D.W. Sep 14 '15 at 16:27
  • In fact, $f$ could be any constant function, but you're still not out of the woods yet. Assuming the domain of the function is the non-negative reals, we'll eventually have $f(n)=f(t)$ for some $t<0$ and then in the next recurrence we'll need to take the square root of a negative number and we're skunked. – Rick Decker Sep 14 '15 at 16:42