OFFSET
1,4
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
Wikipedia, Bitwise operation
FORMULA
a(6*2^n+k) = 8 * min(3,k) * 4^n + a(k), where k is positive and as small as possible. - Charlie Neder, Jul 31 2023
EXAMPLE
a(3) = (0 | 0) + 1 = 0 + 1 = 1,
a(4) = (0 | 1) + 1 = 1 + 1 = 2,
a(5) = (1 | 2) + 1 = 3 + 1 = 4,
a(6) = (2 | 4) + 1 = 6 + 1 = 7,
a(7) = (4 | 7) + 1 = 7 + 1 = 8,
a(8) = (7 | 8) + 1 = 15 + 1 = 16.
MATHEMATICA
a[1] = a[2] = 0; a[n_] := a[n] = BitOr[a[n - 1], a[n - 2]] + 1; Array[a, 55] (* Amiram Eldar, Nov 14 2020 *)
nxt[{a_, b_}]:={b, BitOr[a, b]+1}; NestList[nxt, {0, 0}, 60][[All, 1]] (* Harvey P. Dale, May 08 2021 *)
PROG
(Ruby) values = [0, 0]
30.times { values << (values[-2] | values[-1]) + 1 }
p values
(PARI) lista(nn) = {my(va = vector(nn)); for (n=3, nn, va[n] = bitor(va[n-2], va[n-1]) + 1; ); va; } \\ Michel Marcus, Nov 14 2020
(Python 3.8+) a338888 = lambda n: (0, 0, 1, 2, 4, 7)[n-1] if n<7 else (8*4**(k:=((n-1)//6).bit_length()-1)*min(3, d:=n-6*2**k)+a338888(d)) # Charlie Neder, Jul 31 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Simon Strandgaard, Nov 14 2020
STATUS
approved