OFFSET
0,2
LINKS
Michel Marcus, Table of n, a(n) for n = 0..10000
Christian Krause, LODA program
FORMULA
a(n) = 2*(n+1) - A006519(n+1) = n+1 with a 0 bit inserted above its least significant 1-bit. - Kevin Ryde, Mar 29 2021
a(n) = A129760(n+1) + n+1. - Christian Krause, May 05 2021
MAPLE
N := 127: # for a(0) to a(N)
V := Array(0..N): count := 0:
for i from 1 while count < N+1 do
with(MmaTranslator[Mma]):
f(i) := BitOr(i, i-1);
v := (f(i)-1)/2;
if v <= N and V[v] = 0 then count := count+1; V[v] := i fi
od:
convert(V, list); # Robert Israel, Jan 07 2021
PROG
(PARI) f(n) = bitor(n, n-1); \\ A086799
a(n) = my(k=1); while (f(k) != 2*n+1, k++); k; \\ Michel Marcus, Jan 07 2021
(PARI) a(n) = n++; n<<1 - 1<<valuation(n, 2); \\ Kevin Ryde, Mar 29 2021
(Python)
def A339597(n): return ((m:=n+1)<<1)-(m&-m) # Chai Wah Wu, Sep 01 2023
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Marc LeBrun and N. J. A. Sloane, Jan 06 2021
STATUS
approved