OFFSET
1,2
COMMENTS
This sequence has similarities with the Cantor staircase function.
This sequence can be seen as an irregular table where the n-th row contains A006519(n) times the value n.
For any k > 1, the set of points { (n, a(n)), n = 1..A006520(2^k-1) } is symmetric; for example, for k = 3, we have the following configuration:
a(n)
^
| *
| **
| *
| ****
| *
| **
|*
+-------------> n
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..11264
Wikipedia, Cantor function
FORMULA
a(A006520(n)) = n.
a(A006520(n)+1) = n+1.
a(n) = 2^k + (a(r) if r>0), where k such that k*2^(k-1) < n <= (k+1)*2^k and r = n - (k+2)*2^(k-1). - Kevin Ryde, Jan 18 2021
EXAMPLE
MATHEMATICA
A340619[n_] := Array[n &, Table[BitAnd[BitNot[i - 1], i], {i, 1, n}][[n]]];
Table[A340619[n], {n, 1, 26}] // Flatten (* Robert P. P. McKone, Jan 19 2021 *)
PROG
(PARI) concat(apply(v -> vector(2^valuation(v, 2), k, v), [1..26]))
(PARI) a(n) = my(ret=0); forstep(k=logint(n, 2), 0, -1, if(n > k<<(k-1), ret+=1<<k; n-=(k+2)<<(k-1))); ret; \\ Kevin Ryde, Jan 18 2021
CROSSREFS
KEYWORD
nonn,easy,tabf
AUTHOR
Rémy Sigrist, Jan 13 2021
STATUS
approved