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.

A196168 In binary representation of n: replace each 0 with 1, and each 1 with 10.

This page as a plain text file.
%I A196168 #49 Nov 04 2024 18:28:13
%S A196168 1,2,5,10,11,22,21,42,23,46,45,90,43,86,85,170,47,94,93,186,91,182,
%T A196168 181,362,87,174,173,346,171,342,341,682,95,190,189,378,187,374,373,
%U A196168 746,183,366,365,730,363,726,725,1450,175,350,349,698,347,694,693,1386
%N A196168 In binary representation of n: replace each 0 with 1, and each 1 with 10.
%C A196168 All terms are numbers with no two adjacent zeros in binary representation, cf. A003754;
%C A196168 a(odd) = even and a(even) = odd;
%C A196168 A023416(a(n)) <= A000120(a(n)), equality iff n = 2^k - 1 for k > 0;
%C A196168 A055010(n+1) = A196168(A000079(n));
%C A196168 A000120(a(n)) = A070939(n);
%C A196168 A023416(a(n)) = A000120(n);
%C A196168 A070939(a(n)) = A070939(n) + A000120(n).
%H A196168 Reinhard Zumkeller, <a href="/A196168/b196168.txt">Table of n, a(n) for n = 0..10000</a>
%H A196168 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F A196168 n = Sum_{i=0..1} b(i)*2^i with 0 <= b(i) <= 1, L >= 0, then a(n) = h(0,L) with h(v,i) = if i > L then v, otherwise h((2*v+1)*(b(i)+1),i-1).
%F A196168 From _Jeffrey Shallit_, Oct 28 2021: (Start)
%F A196168 a(n) satisfies the recurrences:
%F A196168 a(2n+1) = 2*a(2n)
%F A196168 a(4n) = -2*a(n) + 3*a(2n)
%F A196168 a(8n+2) = -8*a(n) + 8*a(2n) + a(4n+2)
%F A196168 a(8n+6) = -4*a(2n) + 5*a(4n+2)
%F A196168 which shows that a(n) is a 2-regular sequence. (End)
%e A196168 n =  7 ->  111 ->  101010 ->  a(7) = 42;
%e A196168 n =  8 -> 1000 ->   10111 ->  a(8) = 23;
%e A196168 n =  9 -> 1001 ->  101110 ->  a(9) = 46;
%e A196168 n = 10 -> 1010 ->  101101 -> a(10) = 45;
%e A196168 n = 11 -> 1011 -> 1011010 -> a(11) = 90;
%e A196168 n = 12 -> 1100 ->  101011 -> a(12) = 43.
%t A196168 Table[FromDigits[Flatten[IntegerDigits[n,2]/.{{0->1,1->{1,0}}}],2],{n,0,120}] (* _Harvey P. Dale_, Dec 12 2017 *)
%o A196168 (Haskell)
%o A196168 import Data.List (unfoldr)
%o A196168 a196168 0 = 1
%o A196168 a196168 n = foldl (\v b -> (2 * v + 1)*(b + 1)) 0 $ reverse $ unfoldr
%o A196168    (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 2) n
%o A196168    where r v b = (2 * v + 1)*(b+1)
%o A196168 (Python)
%o A196168 def a(n):
%o A196168     b = bin(n)[2:]
%o A196168     return int(b.replace('1', 't').replace('0', '1').replace('t', '10'), 2)
%o A196168 print([a(n) for n in range(56)]) # _Michael S. Branicky_, Oct 28 2021
%Y A196168 Cf. A179888, A005614.
%K A196168 nonn
%O A196168 0,2
%A A196168 _Reinhard Zumkeller_, Oct 28 2011