Skip to main content
2 of 2
added 241 characters in body
Notamathematician
  • 4.9k
  • 2
  • 11
  • 24

Permutation of the natural numbers from operation related to binary expansion of $n$

  • Let $$ \ell(n) = \left\lfloor\log_2 n\right\rfloor $$

  • Let $T(n,k)$ be a $(k+1)$-th bit from the right side in the binary expansion of $n$. Here $$ T(n, k) = \left\lfloor\frac{n}{2^k}\right\rfloor \operatorname{mod} 2 $$

  • Let $a(n)$ be a sequence of positive integers such that we start with $A:=n$ and then for $0\leqslant i\leqslant \ell(n)$ apply $A:=A + 2^iT(A,\ell(n)-i)$.

  • Let $$ b(n) = \frac{a(2n)-1}{2} - n $$

I conjecture that $b(n)$ is a permutation of natural numbers such that first such that first $2^m-1$ terms are a permutation of the first $2^m-1$ natural numbers for $m\in\mathbb{N}$.

Here is the PARI/GP prog to check it numerically:

a(n) = my(L = logint(n, 2), A = n); for(i=0, L, A += 2^i*bittest(A, L-i)); A
b(n) = (a(2*n) - 1)/2 - n
test(n) = vecsort(vector(2^n-1, i, b(i))) == vector(2^n-1, i, i)

Is there a way to prove it?

Notamathematician
  • 4.9k
  • 2
  • 11
  • 24