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.

A266089 Lexicographically smallest permutation of natural numbers such that in binary representation the number of ones of adjacent terms differ exactly by one.

This page as a plain text file.
%I A266089 #23 Mar 22 2025 11:45:50
%S A266089 0,1,3,2,5,4,6,7,9,8,10,11,12,13,15,14,17,16,18,19,20,21,23,22,24,25,
%T A266089 27,26,29,28,30,31,39,35,33,32,34,37,36,38,40,41,43,42,45,44,46,47,51,
%U A266089 49,48,50,53,52,54,55,57,56,58,59,60,61,63,62,71,67,65
%N A266089 Lexicographically smallest permutation of natural numbers such that in binary representation the number of ones of adjacent terms differ exactly by one.
%H A266089 Reinhard Zumkeller, <a href="/A266089/b266089.txt">Table of n, a(n) for n = 0..10000</a>
%H A266089 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>.
%H A266089 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>.
%F A266089 A266161(n) = A000120(a(n)).
%F A266089 abs(A000120(a(n+1)) - A000120(a(n))) = abs(A266161(n+1) - A266161(n)) = 1.
%e A266089 .   n |  a(n) | A007088(a(n)) | A266161(n)
%e A266089 . ----+-------+---------------+------------
%e A266089 .   0 |    0  |            0  |         0
%e A266089 .   1 |    1  |            1  |         1
%e A266089 .   2 |    3  |           11  |         2
%e A266089 .   3 |    2  |           10  |         1
%e A266089 .   4 |    5  |          101  |         2
%e A266089 .   5 |    4  |          100  |         1
%e A266089 .   6 |    6  |          110  |         2
%e A266089 .   7 |    7  |          111  |         3
%e A266089 .   8 |    9  |         1001  |         2
%e A266089 .   9 |    8  |         1000  |         1
%e A266089 .  10 |   10  |         1010  |         2
%e A266089 .  11 |   11  |         1011  |         3
%e A266089 .  12 |   12  |         1100  |         2
%e A266089 .  13 |   13  |         1101  |         3
%e A266089 .  14 |   15  |         1111  |         4
%e A266089 .  15 |   14  |         1110  |         3
%e A266089 .  16 |   17  |        10001  |         2  .
%t A266089 a[0] = 0; a[n_] := a[n] = Module[{bw = DigitCount[a[n - 1], 2, 1], k = 1}, While[!FreeQ[Array[a, n - 1], k] || Abs[DigitCount[k, 2, 1] - bw] != 1, k++]; k]; Array[a, 100, 0] (* _Amiram Eldar_, Jul 18 2023 *)
%o A266089 (Haskell)
%o A266089 import Data.List (delete)
%o A266089 a266089 n = a266089_list !! n
%o A266089 a266089_list = 0 : f 0 (zip [1..] $ tail a000120_list) where
%o A266089    f x zws = g zws where
%o A266089      g (yw@(y, w) : yws) | abs (x - w) /= 1 = g yws
%o A266089                          | otherwise = y : f w (delete yw zws)
%Y A266089 Cf. A000120, A007088, A108971, A266154 (inverse), A266161.
%K A266089 nonn,base
%O A266089 0,3
%A A266089 _Reinhard Zumkeller_, Dec 22 2015