login
Inverse function to the injection A048724.
6

%I #23 Apr 28 2021 09:59:34

%S 0,0,0,1,0,3,2,0,0,7,6,0,4,0,0,5,0,15,14,0,12,0,0,13,8,0,0,9,0,11,10,

%T 0,0,31,30,0,28,0,0,29,24,0,0,25,0,27,26,0,16,0,0,17,0,19,18,0,0,23,

%U 22,0,20,0,0,21,0,63,62,0,60,0,0,61,56,0,0,57,0,59,58,0,48,0,0,49,0,51,50,0,0,55,54,0,52,0,0,53,32

%N Inverse function to the injection A048724.

%C After a(0)=0, sequence has nonzero values a(n) = k at those positions n for which A048724(k) = n and zeros at those positions n which are not present in A048724.

%C Equally, sequence is obtained when the positive terms of A065620 are replaced with zeros and the sign of the negative terms is reversed.

%H Antti Karttunen, <a href="/A246159/b246159.txt">Table of n, a(n) for n = 0..8191</a>

%F a(n) = (1/2) * A010059(n) * A006068(n).

%F a(n) = -1 * A010059(n) * A065620(n).

%F a(n) = A246160(n) - A065620(n).

%F a(n) = A010059(n) * A006068(A245710(n)).

%F For all n, a(A048724(n)) = n.

%o (Scheme, three different implementations)

%o (define (A246159 n) (* -1 (A010059 n) (A065620 n)))

%o (define (A246159 n) (* (/ 1 2) (A010059 n) (A006068 n)))

%o (define (A246159 n) (* (A010059 n) (A006068 (A245710 n))))

%o (PARI) a065620(n) = if(n<3, n, if(n%2, -2*a065620((n - 1)/2) + 1, 2*a065620(n/2)));

%o a(n) = -!(hammingweight(n)%2)*a065620(n);

%o for(n=0, 100, print1(a(n),", ")) \\ _Indranil Ghosh_, Jun 07 2017

%o (Python)

%o def a065620(n): return n if n<3 else 2*a065620(n//2) if n%2==0 else -2*a065620((n - 1)//2) + 1

%o def a(n): return -(bin(n)[2:].count("1")%2==0)*a065620(n)

%o print([a(n) for n in range(101)]) # _Indranil Ghosh_, Jun 07 2017

%Y Cf. A246160, A006068, A010059, A048724, A065620, A245710.

%K nonn

%O 0,6

%A _Antti Karttunen_, Aug 18 2014