k-Odd, k-Even Sequence [without modulo or ceiling/floor function]

118 Views Asked by At

I am searching for a possibility to generate sequences with k-even numbers followed by k-odd numbers (alternating)

I can use for k = 1

  • $(a_n)_{n \in \mathbb{N_0}} = n$

I can use for k = 2

  • $(b_n)_{n \in \mathbb{N_0}} = \frac n 2 + \frac {(-1)^n} 4 - \frac 1 4 \Rightarrow {0, 0, 1, 1, 2, 2, 3, 3, \cdots}$ (from here)

  • Or via "kleiner Gauß": $(c_n)_{n \in \mathbb{N}} = \frac{n(n+1)}{2} \Rightarrow {1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, \cdots}$ (from here)

How do I get one for any $k\in\mathbb{N}$?

1

There are 1 best solutions below

0
On

For even $k$, start with $k$ zeroes then $k$ ones. Subsequent terms are the sum of the previous $2k-1$ terms:

$0, 0, 0, 0, 1, 1, 1, 1, 4, 8, 16, 32, 63, 125, 249, 497, 990,...$

For odd $k$, start with $k$ zeroes then $k$ ones. Subsequent terms are the sum of the previous $2k-1$ terms, plus 1:

$0, 0, 0, 1, 1, 1, 4, 8, 16, 31, 61, 121, 238, 468, 920, 1809, ...$