What is the name of the function that yields $n$ alternating 1s and 0s?

95 Views Asked by At

Say I have a family of functions $f_n(x)$:

$f_1(1) = 1,f_1(2)= 0,f_1(2) = 1,f_1(3) = 0,\dots$ i.e. when $x= (1,2,3,4,5,6,\dots)$, $f_1(x) = (1,0,1,0,1,0,1,0,\dots)$

$f_2(1) = 1, f_2(2)= 1, f_2(2) = 0, f_2(3) = 0, f_2(4) =1, f_2(5) = 1,\dots$ i.e. when $x= (1,2,3,4,5,6,\dots)$, $f_2(x) = (1,1,0,0,1,1,0,0,\dots)$

For $f_3(x)$, the result is $(1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,\dots)$

For $f_n(x)$, the function yields a sequence of $n$ 1s, followed by a sequence of $n$ 0s, and so on...

What would be the name of this family of functions?

Thank you very much.

1

There are 1 best solutions below

1
On

For this kind of periodic sequences composed of $k$ $1$'s followed by $k$ $0$'s $$a_{n,k}=\frac{\lfloor k+n\rfloor \bmod (2 k)}{k}$$