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.

A092339 Number of adjacent identical digits in the binary representation of n.

This page as a plain text file.
%I A092339 #17 Mar 11 2015 15:19:59
%S A092339 0,0,0,1,1,0,1,2,2,1,0,1,2,1,2,3,3,2,1,2,1,0,1,2,3,2,1,2,3,2,3,4,4,3,
%T A092339 2,3,2,1,2,3,2,1,0,1,2,1,2,3,4,3,2,3,2,1,2,3,4,3,2,3,4,3,4,5,5,4,3,4,
%U A092339 3,2,3,4,3,2,1,2,3,2,3,4,3,2,1,2,1,0,1,2,3,2,1,2,3,2,3,4,5,4,3,4,3,2
%N A092339 Number of adjacent identical digits in the binary representation of n.
%C A092339 In binary: number of 00 blocks plus number of 11 blocks. (Note: the blocks can overlap. See the example below.)
%D A092339 J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 84.
%F A092339 Recurrence: a(2n) = a(n) + [n even], a(2n+1) = a(n) + [n odd].
%F A092339 a(n) = A014081(n) + A056973(n).
%F A092339 For n>0, A227185(n) = a(n)+1.
%F A092339 a(n) = A080791(A003188(n)) [because the sequence gives the number of nonleading zeros in binary Gray code expansion of n] - _Antti Karttunen_, Jul 05 2013
%e A092339 60 in binary is 111100, it has 4 blocks of adjacent digits, so a(60)=4.
%e A092339 Equally, 60's binary Gray code expansion is A003188(60)=34, 100010 in binary, which contains four zeros.
%o A092339 (PARI) a(n)=local(v); v=binary(n); sum(k=1, length(v)-1, v[k]==v[k+1])
%o A092339 (PARI) a(n)=if(n<1,0,if(n%2==0,a(n/2)+(n>0&&(n/2)%2==0),a((n-1)/2)+((n-1)/2)%2))
%o A092339 (Scheme) (define (A092339 n) (A080791 (A003188 n))) ;; _Antti Karttunen_, Jul 05 2013
%Y A092339 Cf. A005811.
%K A092339 nonn,base
%O A092339 0,8
%A A092339 _Ralf Stephan_, Mar 18 2004