1
$\begingroup$

I have a set of integers as follow:

1,2,4,5,7,8,9,10,11,12,13 ...

And I would like to have a close recursive form of the sort 3*(n+1)-1 where, for a given n I can be able to compute the related integer of the sequence.

Unfortunately, the sequence is somehow not uniform, since the difference between consecutive integer is not every time the same:

1,2,1,2,1,1,1,...,1

The problem as one can see, is the two 2 at the second and fourth position of the series given by the 4-2 and 7-5 all the other integers up to infinity as a consecutive difference of 1 (i.e.: 13-12) . So my question is, do exist a close form to express this recurrence of number?

Many thanks for your help.

  • 0
    I am absolutely certain you can do some trickery with floor functions, but I'm not very good at that myself. At least not at getting something nice-looking.2017-01-10
  • 1
    Anyway, this is $n+2$ for $n \ge 5$.2017-01-10
  • 0
    @Crostul yes but what about for `n<5` ? :) this is the tricky point2017-01-10

1 Answers 1

1

Using the floor function $\lfloor \cdot \rfloor$ your sequence can be described by the formula $$n+2-\lfloor \frac{4}{n} \rfloor +2 \cdot\lfloor \frac{1}{n} \rfloor$$

  • 0
    it was what I was searching. I didn't tough about the `floor` function. Many thanks.2017-01-11