login
Binary XOR of (2^k - (-1)^k)/3 as k varies from 1 to n.
3

%I #15 Nov 04 2015 11:22:03

%S 1,0,3,6,13,24,51,102,205,408,819,1638,3277,6552,13107,26214,52429,

%T 104856,209715,419430,838861,1677720,3355443,6710886,13421773,

%U 26843544,53687091,107374182,214748365,429496728,858993459,1717986918,3435973837,6871947672,13743895347

%N Binary XOR of (2^k - (-1)^k)/3 as k varies from 1 to n.

%H Colin Barker, <a href="/A199403/b199403.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (2,0,0,1,-2).

%F G.f.: (3*x^2-2*x+1)*x/(2*x^5-x^4-2*x+1). - _Alois P. Heinz_, Nov 05 2011

%F From _Vladimir Reshetnikov_, Nov 02 2015: (Start)

%F a(n) = (6*cos(Pi*n/2) + 2*sin(Pi*n/2) + 4*2^n - 5*(-1)^n - 5)/10.

%F Recurrence: a(1) = 1, a(2) = 0, a(3) = 3, a(4) = 6, a(5) = 13, a(n) = 2*a(n-1) + a(n-4) - 2*a(n-5).

%F E.g.f.: (2*cosh(2*x) - 5*cosh(x) + 2*sinh(2*x) + 3*cos(x) + sin(x))/5.

%F (End)

%e a(2) = (2^1+1)/3 XOR (2^2-1)/3 = 1 XOR 1 = 0;

%e a(3) = (2^1+1)/3 XOR (2^2-1)/3 XOR (2^3+1)/3 = 1 XOR 1 XOR 3 = 3;

%e a(4) = (2^1+1)/3 XOR (2^2-1)/3 XOR (2^3+1)/3 XOR (2^4-1)/3 = 1 XOR 1 XOR 3 XOR 5 = 6.

%p a:= n-> (<<0|1|0|0|0>, <0|0|1|0|0>, <0|0|0|1|0>, <0|0|0|0|1>, <-2|1|0|0|2>>^n. <<0, 1, 0, 3, 6>>)[1, 1]: seq(a(n), n=1..60); # _Alois P. Heinz_, Nov 05 2011

%t FoldList[BitXor, Table[(2^n - (-1)^n)/3, {n, 1, 20}]] (* _Vladimir Reshetnikov_, Nov 02 2015 *)

%t Table[(6*Cos[Pi n/2] + 2*Sin[Pi n/2] + 4*2^n - 5*(-1)^n - 5)/10, {n, 1, 20}] (* _Vladimir Reshetnikov_, Nov 02 2015 *)

%o (PARI) {a(n)=if(n<0,0,bitxor(a(n-1),((2^n-(-1)^n)/3)))}

%o (PARI) Vec(x*(3*x^2-2*x+1)/((x-1)*(x+1)*(2*x-1)*(x^2+1)) + O(x^100)) \\ _Colin Barker_, Nov 02 2015

%Y Cf. A199402, A199396.

%K nonn,easy

%O 1,3

%A _Paul D. Hanna_, Nov 05 2011