login
Alternating runs of ones and zeros, where the n-th run has length n.
13

%I #41 Jun 19 2024 10:37:21

%S 1,0,0,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,

%T 0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,

%U 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0

%N Alternating runs of ones and zeros, where the n-th run has length n.

%C Seen as a triangle read by rows: T(n,k) = n mod 2, 1<=k<=n. - _Reinhard Zumkeller_, Mar 18 2011

%C a(A007607(n)) = 0; a(A007606(n)) = 1. - _Reinhard Zumkeller_, Dec 30 2011

%C Row sums give A193356. - _Omar E. Pol_, Mar 05 2014

%D K. H. Rosen, Discrete Mathematics and its Applications, 1999, Fourth Edition, page 79, exercise 10 (g).

%H Reinhard Zumkeller, <a href="/A057211/b057211.txt">Rows n=1..125 of triangle, flattened</a>

%H <a href="/index/Ch#char_fns">Index entries for characteristic functions</a>

%F a(n) = (1-(-1)^A002024(n))/2, where A002024(n)=round(sqrt(2*n)). - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Feb 23 2003

%F Also a(n) = A000035(A002024(n)) = A002024(n) mod 2 = A002024(n)-2*floor(A002024(n)/2). - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Feb 23 2003

%F G.f.: x/(1-x)*sum_{n>=0} (-1)^n*x^(n*(n+1)/2). - _Mircea Merca_, Mar 05 2014

%F a(n) = 1 - A057212(n). - _Alois P. Heinz_, Oct 06 2021

%p A002024 := n->round(sqrt(2*n)):A057211 := n->(1-(-1)^A002024(n))/2;

%p # alternative Maple program:

%p T:= n-> [irem(n, 2)$n][]:

%p seq(T(n), n=1..14); # _Alois P. Heinz_, Oct 06 2021

%t Flatten[Table[{PadRight[{},n,1],PadRight[{},n+1,0]},{n,1,21,2}]] (* _Harvey P. Dale_, Jun 07 2015 *)

%o (Haskell)

%o a057211 n = a057211_list !! (n-1)

%o a057211_list = concat $ zipWith ($) (map replicate [1..]) a059841_list

%o -- _Reinhard Zumkeller_, Mar 18 2011

%o (Python)

%o from math import isqrt

%o def A057211(n): return int(bool(isqrt(n<<3)+1&2)) # _Chai Wah Wu_, Jun 19 2024

%Y Cf. A057212, A059841.

%K nonn,tabl

%O 1,1

%A Ben Tyner (tyner(AT)phys.ufl.edu), Sep 27 2000

%E Definition amended by _Georg Fischer_, Oct 06 2021