OFFSET
1,3
LINKS
FORMULA
MATHEMATICA
a[0] = 0; a[1] = 1; a[n_] := If[EvenQ@ n, a[n/2], a[(n - 1)/2] + a[(n + 1)/2]]; Table[BitOr[a[n - 1], a@ n], {n, 120}] (* Michael De Vlieger, Mar 22 2017 *)
PROG
(Scheme) (define (A283986 n) (A003986bi (A002487 (- n 1)) (A002487 n))) ;; Where A003986bi implements bitwise-OR (A003986).
(PARI) A(n) = if(n<2, n, if(n%2, A(n\2) + A((n + 1)/2), A(n/2)));
for(n=1, 101, print1(bitor(A(n - 1), A(n))", ")) \\ Indranil Ghosh, Mar 23 2017
(Python)
from functools import reduce
def A283986(n): return sum(reduce(lambda x, y:(x[0], x[0]+x[1]) if int(y) else (x[0]+x[1], x[1]), bin(n)[-1:2:-1], (1, 0)))|sum(reduce(lambda x, y:(x[0], x[0]+x[1]) if int(y) else (x[0]+x[1], x[1]), bin(n-1)[-1:2:-1], (1, 0))) # Chai Wah Wu, May 05 2023
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Mar 21 2017
STATUS
approved