login
Inverse of A067576 considered as a permutation of the positive integers.
3

%I #20 Mar 02 2023 11:55:08

%S 1,2,3,4,5,8,6,7,12,17,9,23,13,18,10,11,30,38,24,47,31,39,14,57,48,58,

%T 19,69,25,32,15,16,68,80,81,93,94,108,40,107,123,139,49,156,59,70,20,

%U 122,174,193,82,213,95,109,26,234,124,140,33,157,41,50,21,22,138,155,256

%N Inverse of A067576 considered as a permutation of the positive integers.

%H Jianing Song, <a href="/A356419/b356419.txt">Table of n, a(n) for n = 1..10000</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F Let w(n) = A000120(n) be the Hamming weight of n, p(n) = A068076(n), then a(n) = binomial(w(n)+p(n)+1, 2) - p(n).

%e A067576(12) = 9, so a(9) = 12.

%o (PARI) a(n)=my(w=hammingweight(n), p=sum(i=1, n-1, hammingweight(i)==w)); binomial(w+p+1, 2) - p

%o (Python)

%o from math import comb

%o def A356419(n):

%o c, k = 0, 0

%o for i,j in enumerate(bin(n)[-1:1:-1]):

%o if j == '1':

%o k += 1

%o c += comb(i,k)

%o return comb(n.bit_count()+c+1,2)-c # _Chai Wah Wu_, Mar 02 2023

%Y Cf. A067576, A000120, A068076, A263017, A067587.

%K nonn,look,easy

%O 1,2

%A _Jianing Song_, Aug 06 2022