OFFSET
0,2
COMMENTS
From M. F. Hasler, Oct 19 2019: (Start)
This sequence is equal to itself multiplied by 2 and interleaved with the positive even numbers: We have a(2n-1) = 2n (n >= 1) from the very definition, since A006519(m) = 1 for odd m. And a(2n) = 2n + A006519(2n) = 2*a(n), using A006519(2n) = 2*A006519(n).
The sequence repeats the pattern [A, B, C, C] where in the n-th occurrence C = 4n, B = C - 2, A = C if n is even, A = C + 4 if n = 3 (mod 4), and A = 16*a((n-1)/4) otherwise. (End)
LINKS
FORMULA
MATHEMATICA
Table[If[n>0, n + GCD[2^n, n], 0], {n, 0, 100}] (* Indranil Ghosh, Apr 20 2017 *)
PROG
(Scheme)
(Python)
from sympy import gcd
def a(n): return n + gcd(2**n, n) if n>0 else 0 # Indranil Ghosh, Apr 20 2017
(PARI) a(n) = if(n>0, n + gcd(2^n, n), 0); \\ Indranil Ghosh, Apr 20 2017
(PARI) A285326(n)=n+bitand(n, -n) \\ Or: {a(n)=-bitand(-n, bitneg(n))}, not faster. - M. F. Hasler, Oct 19 2019
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Apr 19 2017
STATUS
approved