OFFSET
0,2
COMMENTS
Reversing binary representation of -n. Converting sum of powers of 2 in binary representation of a(n) to alternating sum gives -n. Note that the alternation is applied only to the nonzero bits and does not depend on the exponent of two. All integers have a unique reversing binary representation (see cited exercise for proof). Complement of A065621. - Marc LeBrun, Nov 07 2001
A permutation of the "evil" numbers A001969. - Marc LeBrun, Nov 07 2001
A048725(n) = a(a(n)). - Reinhard Zumkeller, Nov 12 2004
REFERENCES
D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, 1969, Vol. 2, p. 178, (exercise 4.1. Nr. 27)
LINKS
T. D. Noe, Table of n, a(n) for n = 0..1023
P. Mathonet, M. Rigo, M. Stipulanti and N. Zénaïdi, On digital sequences associated with Pascal's triangle, arXiv:2201.06636 [math.NT], 2022.
H. D. Nguyen, A mixing of Prouhet-Thue-Morse sequences and Rademacher functions, 2014. See Example 20. - N. J. A. Sloane, May 24 2014
Ralf Stephan, Some divide-and-conquer sequences ...
Ralf Stephan, Table of generating functions
FORMULA
a(n) = Xmult(n, 3) (or n XOR (n<<1)).
a(n) = A065621(-n).
a(2n) = 2a(n), a(2n+1) = 2a(n) + 2(-1)^n + 1.
G.f. 1/(1-x) * sum(k>=0, 2^k*(3t-t^3)/(1+t)/(1+t^2), t=x^2^k). - Ralf Stephan, Sep 08 2003
a(n) = sum(k=0, n, (1-(-1)^round(+n/2^k))/2*2^k). - Benoit Cloitre, Apr 27 2005
a(n) = A106409(2*n) for n>0. - Reinhard Zumkeller, May 02 2005
a(n) = A142149(2*n). - Reinhard Zumkeller, Jul 15 2008
EXAMPLE
12 = 1100 in binary, 24=11000 and their sum is 10100=20, so a(12)=20.
a(4) = 12 = + 8 + 4 -> - 8 + 4 = -4.
MAPLE
a:= n-> Bits[Xor](n, n+n):
seq(a(n), n=0..100); # Alois P. Heinz, Apr 06 2016
MATHEMATICA
Table[ BitXor[2n, n], {n, 0, 65}] (* Robert G. Wilson v, Jul 06 2006 *)
PROG
(PARI) a(n)=bitxor(n, 2*n) \\ Charles R Greathouse IV, Jan 04 2013
(Haskell)
import Data.Bits (xor, shiftL)
a048724 n = n `xor` shiftL n 1 :: Integer
-- Reinhard Zumkeller, Mar 06 2013
(Python)
def A048724(n): return n^(n<<1) # Chai Wah Wu, Apr 05 2021
CROSSREFS
KEYWORD
AUTHOR
Antti Karttunen, Apr 26 1999
STATUS
approved