[go: up one dir, main page]

login
Run lengths of A228495 (Characteristic function of the odd odious numbers).
3

%I #18 Aug 07 2023 02:12:59

%S 1,1,5,1,3,1,1,1,5,1,1,1,3,1,5,1,3,1,1,1,3,1,5,1,1,1,5,1,3,1,1,1,5,1,

%T 1,1,3,1,5,1,1,1,5,1,3,1,1,1,3,1,5,1,3,1,1,1,5,1,1,1,3,1,5,1,3,1,1,1,

%U 3,1,5,1,1,1,5,1,3,1,1,1,3,1,5,1,3,1,1,1,5,1,1,1,3,1,5,1,1

%N Run lengths of A228495 (Characteristic function of the odd odious numbers).

%C Also run lengths of A254377 = 1-A228495(n).

%H Antti Karttunen, <a href="/A254378/b254378.txt">Table of n, a(n) for n = 1..65537</a>

%e A228495 begins 0,1,0,0,0,0,0,1,0, hence this sequence begins 1,1,5,1.

%t Length /@ Split[Table[If[OddQ[n] && OddQ[DigitCount[n, 2, 1]], 1, 0], {n, 0, 200}]] (* _Amiram Eldar_, Aug 07 2023 *)

%o (PARI)

%o up_to = 65537;

%o A254378lista(up_to) = { my(v=vector(up_to), r=1, n=0, i=1, pb=0, b); while(n<up_to, b = (hammingweight(i)%2)*(i%2); if(b==pb, r++, n++; v[n] = r; r = 1; pb = b); i++); (v); }; \\ _Antti Karttunen_, Oct 01 2018

%o v254378 = A254378lista(up_to);

%o A254378(n) = v254378[n]; \\ _Antti Karttunen_, Oct 01 2018

%o (Python)

%o from itertools import count, islice, groupby

%o def A254378_gen(): # generator of terms

%o return (len(list(g)) for k, g in groupby(n.bit_count()&1&n for n in count(0)))

%o A254378_list = list(islice(A254378_gen(),20)) # _Chai Wah Wu_, Mar 09 2023

%Y Cf. A228495, A254377, A254655.

%K nonn,base

%O 1,3

%A _Jeremy Gardiner_, Jan 29 2015