A114375 a(n) = (a(n-1) XOR a(n-2)) + 1, a(0) = a(1) = 0.
0, 0, 1, 2, 4, 7, 4, 4, 1, 6, 8, 15, 8, 8, 1, 10, 12, 7, 12, 12, 1, 14, 16, 31, 16, 16, 1, 18, 20, 7, 20, 20, 1, 22, 24, 15, 24, 24, 1, 26, 28, 7, 28, 28, 1, 30, 32, 63, 32, 32, 1, 34, 36, 7, 36, 36, 1, 38, 40, 15, 40, 40, 1, 42, 44, 7, 44, 44, 1, 46, 48, 31, 48, 48, 1, 50, 52, 7, 52, 52, 1
Offset: 0
Keywords
Examples
G.f. = x^2 + 2*x^3 + 4*x^4 + 7*x^5 + 4*x^6 + 4*x^7 + x^8 + 6*x^9 + 8*x^10 + ...
Links
- Harvey P. Dale, Table of n, a(n) for n = 0..1000
Programs
-
Mathematica
a[ n_] := If[ n < 0, BitXor[ a[n + 1], a[n + 2] - 1], If[n < 2, 0, 1 + BitXor[ a[n - 1], a[n - 2]]]]; (* Michael Somos, Mar 03 2014 *) a[ n_] := If[ Mod[n, 3] == 0, 2 n/3, If[ Mod[n, 3] == 1, 4 Quotient[n + 3, 6], If[ n == -1, -1, 2^IntegerExponent[ Fibonacci[n + 1], 2] - 1]]]; (* Michael Somos, Mar 03 2014 *) nxt[{a_,b_}]:={b,BitXor[a,b]+1}; NestList[nxt,{0,0},80][[All,1]] (* Harvey P. Dale, Feb 26 2020 *)
Formula
a(3n)=2n. a(3n+1)=4*floor((n+1)/2). a(6n+2)=1. a(6n+5)=2^(A001511(n+1)+2)-1.
a(-n) = -a(n) if n == 0 (mod 3), a(-1-n) = -a(n) if n == 1 (mod 3), a(-2-n) = a(n) if n == 2 (mod 3). - Michael Somos, Mar 03 2014
Comments