Following is the recurrence relation:
a[1] = 1;
a[n_] := a[n - a[n - 1]] + 1
Array[a, 28]
I tried to use RSolve, but it doesn't gives a correct answer.
Clear[a]
RSolve[{a[n] == a[n - a[n - 1]] + 1}, a[n], a]
|
Following is the recurrence relation:
I tried to use
|
|||
|
|
|
First, I believe your
This gives a more informative (error?) message:
Apparently Second, your recursive function is very inefficient because it lacks memoization. Adding that will make it more practical:
Finally, we can work out a function for the nth term manually. Observe that in your sequence each number n repeats n times:
The jump points are therefore triangular numbers:
We can invert this equation with
Then pick the correct branch and add
Now:
|
|||||||
|