How can I solve this recursive function $f(n) = f(f(n+1))$?

193 Views Asked by At

I am trying to solve this: $$ f(n) = \begin{cases} n - 1,& n > 5\\ f(f(n+1)),& n\leqslant 5 \end{cases} $$

What is the technical name of this kind of function ? --> $f(f(n+1))$

A function within another function?

\begin{align} f(1) &= f(f(1+1)) = f(f(2)) \\ f(2) &= f(f(2+1)) = f(f(3))\\ f(3) &= f(f(3+1)) = f(f(4))\\ f(4) &= f(f(4+1)) = f(f(5))\\ f(5) &= 5 - 1 = 4\\ f(6) &= 6 - 1 = 5\\ f(7) &= 7 - 1 = 6 \end{align}

I can only find the answer when $n > 5$. When $n\leqslant5$, I can only see $f(f(k))$. How to find the answers of $f(1)$, $f(2)$, $f(3)$ and $f(4)$ ? Thank you very much.

2

There are 2 best solutions below

5
On

An example will make it understand better

$ {let}$ $ n = 5$ now $ f(n)=f(f(n=1))$

so, $f(5)=f(f(5+1))$

$=f(f(6)) = f(5)$

$f(5)=f(f(5+1))$

$=f(f(6)) = f(5)$

$f(5)=f(f(5+1))$

$=f(f(6)) = f(5)$

.............. and it goes on so the function is not defined at 5

Now let $n=4$

so, $f(3)=f(f(3+1))$

$=f(f(4))$ now $f(4)$ will be $f(f(5))$ so, $f(3)=f(f(4))=f(f(f(5)))$

which again is not defined,

so we can say that the function is of indeterminate form for $n\leqslant5$

0
On

This is a partial answer to the first part of your question:

What is the technical name of this kind of function?

Your function seems to be a cousin of McCarthy 91 function, originally given as an example of a function with a complex recursion pattern.

Quoting wikipedia, it is considered as a challenge problem for automated program verification.