2

The sequence is

0,1,1/2,0,1/3,2/3,1,3/4,2/4,1/4,0,1/5,2/5,3/5,4/5,1,5/6,4/6,3/6,2/6,1/6,0,1/7,....

it is from the top answer to this question

I considered some closed-form definitions involving modulo but I can't take the descending part of the sequence into the definition.

1 Answers1

2

Hint (or rather, a way to argue, without including the calculations):

  1. First try it backwards: if you know the denominator $d$, find a formula for the index of the first term containing it, $n(d)$. E.g. for $d=5$, $n(d)=11$ because the 11th term is $0=\frac 0 5$ (after which $\frac 1 5, \frac 2 5,\ldots$ follow).

  2. Next, invert the formula you got above: write $n = n(d)$ (where $n(d)$ is the expression you got above) and solve for $d$.
    That will work only if $n$ is the first term in the sequence having a particular denominator. For bigger $n$, you'll get a fractional $d$ - no problem, take the floor function, $\textrm{floor}(d(n))$!

  3. Now for any $n$ you know the denominator. From the denominator, you also know the first term that has it, and hence you have the offset of your $n$:
    For example, for the 8th term you know the denominator is 4 and the first term that has it is the 7th one, so the 8th term is the second one to use it.

  4. From the offset you can easily tell the numerator of the $n$th term.

    1. For odd denominators, the sequence goes upwards $\frac 0 {2k+1}, \frac 1{2k+1}, \frac 2 {2k+1}, \ldots$, while for even it goes downwards $\frac {2k} {2k}, \frac {2k-1} {2k} , \ldots , \frac 1 {2k}$.
    2. To choose the proper one with a closed form you can either try to think about it, or just take the siliest solution that works: $$\frac 1 2 (1 + (-1)^d)\frac i d + \frac 1 2 (1 + (-1)^{d+1})\frac {d-i} d.$$ Here even values of $d$ "turn on" the first term while odd $d$s turn on only the second term.
  5. Since now you have, given $n$, a closed formula for the denominator $d$ and the offset $i$, and a closed formula for the numerator (given $i,d$), now you have a closed formula for the whole fraction, too.

Al.G.
  • 1,802