cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A368843 a(n) gives the number of triples of equally spaced 1's in the binary expansion of n.

This page as a plain text file.
%I A368843 #12 Jan 10 2024 12:15:15
%S A368843 0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,2,0,0,0,0,0,1,0,2,0,0,0,0,1,2,2,4,0,0,
%T A368843 0,0,0,0,0,1,0,0,1,1,0,0,2,3,0,0,0,0,0,1,0,2,1,1,2,2,2,3,4,6,0,0,0,0,
%U A368843 0,0,0,1,0,1,0,1,0,1,1,3,0,0,0,0,1,2,1
%N A368843 a(n) gives the number of triples of equally spaced 1's in the binary expansion of n.
%H A368843 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F A368843 a(2*n) = a(n).
%F A368843 a(2*n + 1) >= a(n).
%e A368843 For n = 277:
%e A368843 - the binary expansion of 277 is "100010101",
%e A368843 - we have the following triples:  1   1   1
%e A368843                                       1 1 1
%e A368843 - so a(277) = 2.
%o A368843 (PARI) a(n, t = 1, base = 2) = { my (d = digits(n, base), v = 0); for (i = 1, #d-2, if (d[i]==t, forstep (j = i+2, #d, 2, if (d[i]==d[j] && d[i]==d[(i+j)/2], v++;);););); return (v); }
%o A368843 (Python)
%o A368843 def A368843(n):
%o A368843     l = len(s:=bin(n)[2:])
%o A368843     return sum(1 for i in range(l-2) for j in range(1,l-i+1>>1) if s[i:i+(j<<1)+1:j]=='111') # _Chai Wah Wu_, Jan 10 2024
%Y A368843 Cf. A368842, A368844.
%K A368843 nonn,base,easy
%O A368843 0,16
%A A368843 _Rémy Sigrist_, Jan 07 2024