A166711 Permutation of the integers: two positives, one negative.
0, 1, 2, -1, 3, 4, -2, 5, 6, -3, 7, 8, -4, 9, 10, -5, 11, 12, -6, 13, 14, -7, 15, 16, -8, 17, 18, -9, 19, 20, -10, 21, 22, -11, 23, 24, -12, 25, 26, -13, 27, 28, -14, 29, 30, -15, 31, 32, -16, 33, 34, -17, 35, 36, -18, 37, 38, -19, 39, 40, -20, 41, 42, -21, 43, 44, -22, 45, 46
Offset: 0
Links
- G. C. Greubel, Table of n, a(n) for n = 0..10000
- Wikipedia, Riemann series theorem
- Index entries for linear recurrences with constant coefficients, signature (0,0,2,0,0,-1).
Programs
-
Mathematica
LinearRecurrence[{0, 0, 2, 0, 0, -1}, {0, 1, 2, -1, 3, 4}, 100] (* G. C. Greubel, May 24 2016 *) Join[{0},With[{nn=50},Riffle[Range[nn],Range[-1,-nn/2,-1],3]]] (* Harvey P. Dale, May 15 2023 *)
-
PARI
a(n)=(2*(n+1)\3)*(1-3/2*!(n%3))
-
PARI
a(n)=if(n>=0,[ -n\3, 2*(n\3)+1, 2*(n\3)+2][n%3+1]) \\ Jaume Oliver Lafont, Nov 14 2009
Formula
G.f.: (x*(1+2*x-x^2+x^3)/((1-x)^2*(1+x+x^2)^2)).
a(0)=0, a(1)=1, a(2)=2, a(3)=-1, a(4)=3, a(5)=4, a(n)=2*a(n-3)-a(n-6), n>=6.
Extensions
Corrected by Jaume Oliver Lafont, Oct 22 2009
frac keyword removed by Jaume Oliver Lafont, Nov 02 2009
Comments