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.

A357961 a(1) = 1, and for any n > 0, a(n+1) is the k-th positive number not yet in the sequence, where k is the Hamming weight of a(n).

This page as a plain text file.
%I A357961 #36 Oct 30 2022 15:08:45
%S A357961 1,2,3,5,6,7,9,8,4,10,12,13,15,17,14,18,16,11,21,22,23,25,24,20,26,28,
%T A357961 29,31,33,27,34,30,36,32,19,38,39,41,40,37,43,45,46,47,49,44,48,42,51,
%U A357961 53,54,55,57,56,52,58,60,61,63,65,50,62,67,64,35,68,66
%N A357961 a(1) = 1, and for any n > 0, a(n+1) is the k-th positive number not yet in the sequence, where k is the Hamming weight of a(n).
%C A357961 This sequence is a permutation of the positive integers:
%C A357961 - Let e = A000523 and w = A000120.
%C A357961 - Lemma: a(n) <= n + e(n)
%C A357961     - This property is true for n = 1.
%C A357961     - Assume that a(n) <= n + e(n) for some n >= 1.
%C A357961     - Then a(n+1) <= n + w(a(n))
%C A357961                   <= n + e(a(n))
%C A357961                   <= n + e(n + e(n))
%C A357961                   <= n + e(2*n)
%C A357961                   <= n + 1 + e(n)
%C A357961                   <= n + 1 + e(n + 1) - QED.
%C A357961 - If this sequence is not a permutation, then some number is missing.
%C A357961 - Let v be the least number that does not appear in the sequence.
%C A357961 - At some point, v is the least number not yet in the sequence.
%C A357961 - From now on, powers of 2 can no longer appear in the sequence.
%C A357961 - So there are infinitely many numbers that do not appear in the sequence.
%C A357961 - Let w be the least number > v that does not appear in the sequence.
%C A357961 - At some point, v and w are the two least numbers not yet in the sequence.
%C A357961 - Say this happens after m terms and max(a(1), ..., a(m)) < 2^k (with k > 0).
%C A357961 - From now on, powers of 2 and sums of two powers of 2 can no longer appear.
%C A357961 - So the numbers 2^k, 2^k + 2^i where i = 0..k-1 won't appear,
%C A357961   and the numbers 2^(k+1), 2^(k+1) + 2^i where i = 0..k won't appear.
%C A357961 - So among the first 2^(k+2) terms, by the pigeonhole principle,
%C A357961   we necessarily have a term a(n) >= 2^(k+2) + 2*k + 3.
%C A357961 - But we also know that a(n) <= 2^(k+2) + e(2^(k+2)) = 2^(k+2) + k + 2.
%C A357961 - This is a contradiction - QED.
%C A357961 Conjecture: this permutation has only finite cycles because it appears that for each interval a(1..2^m) the maximal observed displacement is smaller than 2^m and this maximal displacement is realized by only one element in this interval for m > 3. - _Thomas Scheuerle_, Oct 22 2022
%H A357961 Rémy Sigrist, <a href="/A357961/b357961.txt">Table of n, a(n) for n = 1..10000</a>
%H A357961 Thomas Scheuerle, <a href="/A357961/a357961.png">Scatter plot of log_2(2^4 + n - a(n)) for n = 1..10000</a>
%H A357961 Rémy Sigrist, <a href="/A357961/a357961_1.gp.txt">PARI program</a>
%H A357961 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A357961 a(n) <= n + A000523(n).
%F A357961 Empirically: a(n) = n + A000523(n) iff n = 1 or n belong to A132753 \ {3, 4}.
%e A357961 The first terms, alongside their Hamming weight and the values not yet in the sequence so far, are:
%e A357961   n   a(n)  A000120(a(n))  values not yet in the sequence
%e A357961   --  ----  -------------  ---------------------------------------------
%e A357961    1     1              1  { 2,  3,  4,  5,  6,  7,  8,  9, 10, 11, ...}
%e A357961    2     2              1  { 3,  4,  5,  6,  7,  8,  9, 10, 11, 12, ...}
%e A357961    3     3              2  { 4,  5,  6,  7,  8,  9, 10, 11, 12, 13, ...}
%e A357961    4     5              2  { 4,  6,  7,  8,  9, 10, 11, 12, 13, 14, ...}
%e A357961    5     6              2  { 4,  7,  8,  9, 10, 11, 12, 13, 14, 15, ...}
%e A357961    6     7              3  { 4,  8,  9, 10, 11, 12, 13, 14, 15, 16, ...}
%e A357961    7     9              2  { 4,  8, 10, 11, 12, 13, 14, 15, 16, 17, ...}
%e A357961    8     8              1  { 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, ...}
%e A357961    9     4              1  {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...}
%e A357961   10    10              2  {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...}
%e A357961   11    12              2  {11, 13, 14, 15, 16, 17, 18, 19, 20, 21, ...}
%e A357961   12    13              3  {11, 14, 15, 16, 17, 18, 19, 20, 21, 22, ...}
%e A357961   13    15              4  {11, 14, 16, 17, 18, 19, 20, 21, 22, 23, ...}
%e A357961   14    17              2  {11, 14, 16, 18, 19, 20, 21, 22, 23, 24, ...}
%e A357961   15    14              3  {11, 16, 18, 19, 20, 21, 22, 23, 24, 25, ...}
%e A357961   16    18              2  {11, 16, 19, 20, 21, 22, 23, 24, 25, 26, ...}
%o A357961 (PARI) See Links section.
%o A357961 (MATLAB)
%o A357961 function a = A357961( max_n )
%o A357961     a = 1;
%o A357961     num = [2:max_n*floor(log2(max_n))];
%o A357961     for n = 2:max_n
%o A357961         k = num(length(find(bitget(a(n-1),1:64)==1)));
%o A357961         a(n) = k; num(num == k) = [];
%o A357961     end
%o A357961 end % _Thomas Scheuerle_, Oct 22 2022
%Y A357961 Cf. A000120, A000523, A132753, A217122, A357993, A358057 (inverse).
%K A357961 nonn,base
%O A357961 1,2
%A A357961 _Rémy Sigrist_, Oct 22 2022