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.

A165199 a(n) is obtained by flipping every second bit in the binary representation of n starting at the second-most significant bit and on downwards.

This page as a plain text file.
%I A165199 #48 Oct 11 2023 04:40:14
%S A165199 0,1,3,2,6,7,4,5,13,12,15,14,9,8,11,10,26,27,24,25,30,31,28,29,18,19,
%T A165199 16,17,22,23,20,21,53,52,55,54,49,48,51,50,61,60,63,62,57,56,59,58,37,
%U A165199 36,39,38,33,32,35,34,45,44,47,46,41,40,43,42,106,107,104,105,110,111,108
%N A165199 a(n) is obtained by flipping every second bit in the binary representation of n starting at the second-most significant bit and on downwards.
%C A165199 This is a self-inverse permutation of the positive integers.
%C A165199 Old name was: a(0) = 0, and for n>=1, let b(n,m) be the m-th digit, reading left to right, of binary n. (b(n, 1) is the most significant binary digit, which is 1.) Then a(n) is such that b(a(n),1)=1; and if b(n,m)=b(n,m-1) then b(a(n),m) does not = b(a(n),m-1); and if b(n,m) does not = b(n,m-1) then b(a(n), m) = b(a(n),m-1), for all m where 2 <= m <= number binary digits in n.
%C A165199 From _Emeric Deutsch_, Oct 06 2020: (Start)
%C A165199 a(n) is the index of the composition that is the conjugate of the composition with index n.
%C A165199 The index of a composition is defined to be the positive integer whose binary form has run-lengths (i.e., runs of 1's, runs of 0's, etc. from left to right) equal to the parts of the composition. Example: the composition 1,1,3,1 has index 46 since the binary form of 46 is 101110.
%C A165199 a(18) = 24. Indeed, since the binary form of 18 is 10010, the composition with index 18 is 1,2,1,1 (the run-lengths of 10010); the conjugate of 1,2,1,1 is 2,3 and so the binary form of a(18) is 11000; consequently, a(18) = 24. (End)
%H A165199 Antti Karttunen, <a href="/A165199/b165199.txt">Table of n, a(n) for n = 0..1023</a>
%H A165199 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%H A165199 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A165199 From _Antti Karttunen_, Jul 22 2014: (Start)
%F A165199 a(0) = 0, and for n >= 1, a(n) = 2*a(floor(n/2)) + A000035(n+A000523(n)).
%F A165199 As a composition of related permutations:
%F A165199 a(n) = A056539(A129594(n)) = A129594(A056539(n)).
%F A165199 a(n) = A245443(A193231(n)) = A193231(A245444(n)).
%F A165199 a(n) = A075158(A243353(n)-1) = A075158((A241909(1+A075157(n))) - 1).
%F A165199 (End)
%F A165199 a(n) = A258746(A054429(n)) = A054429(A258746(n)), n > 0. - _Yosu Yurramendi_, Mar 29 2017
%e A165199 a(12) = 9 because 12 = 1100_2 and 1100_2 XOR 0101_2 = 1001_2 = 9.
%p A165199 a:= n-> Bits[Xor](n, iquo(2^(1+ilog2(n)), 3)):
%p A165199 seq(a(n), n=0..100);  # _Alois P. Heinz_, Oct 07 2020
%o A165199 (Scheme, with memoizing definec-macro)
%o A165199 (definec (A165199 n) (if (zero? n) n (+ (* 2 (A165199 (floor->exact (/ n 2)))) (A000035 (+ (A000523 n) n)))))
%o A165199 ;; _Antti Karttunen_, Jul 22 2014
%o A165199 (R)
%o A165199 maxrow <- 8 # by choice
%o A165199 a <- 1
%o A165199 for(m in 0: maxrow) for(k in 0:(2^m-1)){
%o A165199 a[2^(m+1) +       k] = a[2^(m+1) - 1 - k] + 2^(m+1)
%o A165199 a[2^(m+1) + 2^m + k] = a[2^(m+1) - 1 - k] + 2^m
%o A165199 }
%o A165199 (a <- c(0, a))
%o A165199 # _Yosu Yurramendi_, Apr 04 2017
%o A165199 (PARI) for(k=0,67,my(b(n)=vector(#digits(n,2),i,!(i%2)));print1(bitxor(k,fromdigits(b(k),2)),", ")) \\ _Hugo Pfoertner_, Oct 07 2020
%o A165199 (PARI) a(n) = if(n, bitxor(n,2<<logint(n,2)\3), 0); \\ _Kevin Ryde_, Oct 07 2020
%Y A165199 Cf. A000035, A000523, A075157, A075158, A241909, A243353, A245443, A245444.
%Y A165199 {A001477, A129594, A165199, A056539} form a 4-group.
%K A165199 base,nonn,look
%O A165199 0,3
%A A165199 _Leroy Quet_, Sep 07 2009
%E A165199 Extended by _Ray Chandler_, Sep 10 2009
%E A165199 a(0) = 0 prepended by _Antti Karttunen_, Jul 22 2014
%E A165199 New name from _Kevin Ryde_, Oct 07 2020