OFFSET
1,1
COMMENTS
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..8191
Daniel M. Kane, Carlo Sanna, and Jeffrey Shallit, Waring's Theorem for Binary Powers, Combinatorica, Vol. 39, No. 6 (2019), pp. 1335-1350, arXiv preprint, arXiv:1801.04483 [math.NT], 2018.
Parthasarathy Madhusudan, Dirk Nowotka, Aayush Rajasekaran, and Jeffrey Shallit, Lagrange's Theorem for Binary Squares, arXiv:1710.04247 [math.NT], 2017-2018.
Manfred Madritsch and Stephan Wagner, A central limit theorem for integer partitions, Monatshefte für Mathematik, Vol. 161, No. 1 (2010), pp. 85-114, alternative link.
Aayush Rajasekaran, Using Automata Theory to Solve Problems in Additive Number Theory, MS thesis, University of Waterloo, 2018.
FORMULA
a(n) = n + 2*n*2^floor(log_2(n)). - Ralf Stephan, Dec 07 2004
Sum_{n>=1} 1/a(n) = A330157. - Amiram Eldar, Oct 22 2020
a(n) = n * (2^A070939(n) + 1). - Jianing Song, Apr 10 2021
EXAMPLE
36 is a term because 36 = 100100_2, which is 100 followed by 100.
MAPLE
a:= n-> (l-> Bits[Join]([l[], l[]]))(Bits[Split](n)):
seq(a(n), n=1..50); # Alois P. Heinz, Aug 24 2024
MATHEMATICA
Table[n + 2 n 2^Floor[Log[2, n]], {n, 50}] (* T. D. Noe, Dec 10 2013 *)
FromDigits[#, 2] & /@ (# <> # & /@ IntegerString[Range@100, 2]) (* Hans Rudolf Widmer, Aug 24 2024 *)
PROG
(Haskell)
a020330 n = foldr (\d v -> 2 * v + d) 0 (bs ++ bs) where
bs = a030308_row n
-- Reinhard Zumkeller, Feb 19 2013
(PARI) a(n)=n+n<<#binary(n) \\ Charles R Greathouse IV, Mar 29 2013
(PARI) is(n)=my(L=#binary(n)\2); n>>L==bitand(n, 2^L-1) \\ Charles R Greathouse IV, Mar 29 2013
(Magma) [n+2*n*2^Floor(Log(2, n)): n in [1..50]]; // Vincenzo Librandi, Apr 05 2018
(Python)
def a(n): return int(bin(n)[2:]*2, 2)
print([a(n) for n in range(1, 51)]) # Michael S. Branicky, Mar 10 2021
(Python)
def A020330(n): return (n<<n.bit_length())|n # Chai Wah Wu, Feb 28 2023
CROSSREFS
KEYWORD
AUTHOR
David W. Wilson, Melia Aldridge (ma38(AT)spruce.evansville.edu)
STATUS
approved