Closed form representation of recurrence relation 4

65 Views Asked by At

I want to find a closed form of the following recurrence relation:

$$ a_0=0; \\ a_{n+1}=\begin{cases}0, & \exists k\in \mathbb{N}_0: n=\frac12 k(k+1); \\ a_n+1, & \nexists k \in \mathbb{N}_0:n=\frac12 k(k+1). \end{cases} $$

(In particular, this recurrence relation describes the sequence $$ (0,0,1,0,1,2,0,1,2,3,0,1,2,\ldots) $$ .)

I was not successful in finding an adequate generating function as normal. How can I proceed?

1

There are 1 best solutions below

0
On

Adapting the Mathematica results from https://oeis.org/A002262, if we define

$$ m(k)=\left\lfloor \frac{\sqrt{8k-7}-1}{2}\right\rfloor\quad\text{ for }k\ge1 $$

then

$$ a_k= k-m(k+1)\cdot\frac{m(k+1)+1}{2}$$

This produces the sequence

$$ (0,0,1,0,1,2,0,1,2,3,0,1,2,3,4,0,1,2,3,4,5,0,\ldots) $$