cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-3 of 3 results.

A003815 a(0) = 0, a(n) = a(n-1) XOR n.

Original entry on oeis.org

0, 1, 3, 0, 4, 1, 7, 0, 8, 1, 11, 0, 12, 1, 15, 0, 16, 1, 19, 0, 20, 1, 23, 0, 24, 1, 27, 0, 28, 1, 31, 0, 32, 1, 35, 0, 36, 1, 39, 0, 40, 1, 43, 0, 44, 1, 47, 0, 48, 1, 51, 0, 52, 1, 55, 0, 56, 1, 59, 0, 60, 1, 63, 0, 64, 1, 67, 0
Offset: 0

Views

Author

Keywords

Crossrefs

Cf. A003816.
Cf. A077140, A145768. - M. F. Hasler, Oct 20 2008

Programs

  • Mathematica
    an = 0; Reap[ For[i = 0, i <= 100, i++, an = BitXor[an, i]; Sow[an]]][[2, 1]] (* Jean-François Alcover, Oct 11 2013, translated from PARI *)
    CoefficientList[Series[x (1 + 3 x - x^2 + x^3)/((1 - x^4) (1 - x^2)), {x, 0, 100}], x] (* Vincenzo Librandi, Oct 12 2013 *)
    nxt[{n_,a_}]:={n+1,BitXor[n+1,a]}; NestList[nxt,{0,0},70][[All,2]] (* Harvey P. Dale, Mar 10 2019 *)
    {#,1,#+1,0}[[1+Mod[#,4]]]&/@Range[0,100] (* Federico Provvedi, May 10 2021 *)
  • PARI
    print1(an=0); for( i=1,100, print1(",",an=bitxor(an,i))) \\ M. F. Hasler, Oct 20 2008

Formula

a(n) = n + (-1)^n*a(n-1). - Vladeta Jovovic, Mar 13 2003
a(0)=0, a(4n+1)=1, a(4n+2)=4n+3, a(4n+3)=0, a(4n+4)=4n+4, n >= 0.
a(n) = f(n,0) with f(n,x) = x if n=0, otherwise f(n-1,x+n) if x is even, otherwise f(n-1,x-n). - Reinhard Zumkeller, Oct 09 2007
a(n) = abs(A077140(n)) for n > 0. - Reinhard Zumkeller, Oct 09 2007
G.f.: x*(1+3*x-x^2+x^3)/((1-x^4)*(1-x^2)). - Vincenzo Librandi, Oct 12 2013
a(n) = (1 + n + n*(-1)^n + (-1)^floor((n-1)/2))/2. - Wesley Ivan Hurt, May 08 2021

A319674 a(n) = 1 + 2 + 3 - 4 - 5 - 6 + 7 + 8 + 9 - 10 - 11 - 12 + ... - (up to n).

Original entry on oeis.org

1, 3, 6, 2, -3, -9, -2, 6, 15, 5, -6, -18, -5, 9, 24, 8, -9, -27, -8, 12, 33, 11, -12, -36, -11, 15, 42, 14, -15, -45, -14, 18, 51, 17, -18, -54, -17, 21, 60, 20, -21, -63, -20, 24, 69, 23, -24, -72, -23, 27, 78, 26, -27, -81, -26, 30, 87, 29, -30, -90, -29
Offset: 1

Views

Author

Wesley Ivan Hurt, Sep 25 2018

Keywords

Comments

In general, for sequences that add the first k natural numbers and then subtract the next k natural numbers, and continue to alternate in this way up to n, we have a(n) = Sum_{i=1..n} i*(-1)^floor((i-1)/k). Here, k=3.

Examples

			a(1) = 1;
a(2) = 1 + 2 = 3;
a(3) = 1 + 2 + 3 = 6;
a(4) = 1 + 2 + 3 - 4 = 2;
a(5) = 1 + 2 + 3 - 4 - 5 = -3;
a(6) = 1 + 2 + 3 - 4 - 5 - 6 = -9;
a(7) = 1 + 2 + 3 - 4 - 5 - 6 + 7 = -2;
a(8) = 1 + 2 + 3 - 4 - 5 - 6 + 7 + 8 = 6;
a(9) = 1 + 2 + 3 - 4 - 5 - 6 + 7 + 8 + 9 = 15;
a(10) = 1 + 2 + 3 - 4 - 5 - 6 + 7 + 8 + 9 - 10 = 5; etc.
		

Crossrefs

Cf. A001057 (k=1), A077140 (k=2), this sequence (k=3).

Programs

  • Mathematica
    Table[Sum[i (-1)^Floor[(i - 1)/3], {i, n}], {n, 60}]
    Accumulate[Flatten[If[EvenQ[#[[1]]],-#,#]&/@Partition[Range[70],3]]] (* or *) LinearRecurrence[{1,0,-2,2,0,-1,1},{1,3,6,2,-3,-9,-2},70] (* Harvey P. Dale, Sep 15 2021 *)
  • PARI
    Vec(x*(1 + 2*x + 3*x^2 - 2*x^3 - x^4) / ((1 - x)*(1 + x)^2*(1 - x + x^2)^2) + O(x^60)) \\ Colin Barker, Sep 26 2018

Formula

a(n) = Sum_{i=1..n} i*(-1)^floor((i-1)/3).
From Colin Barker, Sep 26 2018: (Start)
G.f.: x*(1 + 2*x + 3*x^2 - 2*x^3 - x^4) / ((1 - x)*(1 + x)^2*(1 - x + x^2)^2).
a(n) = a(n-1) - 2*a(n-3) + 2*a(n-4) - a(n-6) + a(n-7) for n>7.
(End)
Conjectures from Bill McEachen, Dec 19 2024: (Start)
For a(n)>0 and n=A047235(m), a(n) = n/2 + 2*Mod(m,2), otherwise a(n) = 3*(n+1)/2.
For a(n)<0 and n=A007310(m), a(n)= 1 + (1-n)/2 + 2*(Mod(m,2)-1), otherwise a(n) = -3*n/2. (End)

A267314 Expansion of 2*x*(1 + 2*x - x^2)/((1 - x)*(1 + x^2)^2).

Original entry on oeis.org

0, 2, 6, 0, -8, 2, 14, 0, -16, 2, 22, 0, -24, 2, 30, 0, -32, 2, 38, 0, -40, 2, 46, 0, -48, 2, 54, 0, -56, 2, 62, 0, -64, 2, 70, 0, -72, 2, 78, 0, -80, 2, 86, 0, -88, 2, 94, 0, -96, 2, 102, 0, -104, 2, 110, 0, -112, 2, 118, 0, -120, 2, 126, 0, -128, 2, 134, 0, -136, 2, 142, 0
Offset: 0

Views

Author

Ilya Gutkovskiy, Jan 13 2016

Keywords

Examples

			a(0) = 0;
a(1) = 0 + 2 = 2;
a(2) = 0 + 2 + 4 = 6;
a(3) = 0 + 2 + 4 - 6 = 0;
a(4) = 0 + 2 + 4 - 6 - 8 = -8;
a(5) = 0 + 2 + 4 - 6 - 8 + 10 = 2;
a(6) = 0 + 2 + 4 - 6 - 8 + 10 + 12 = 14;
a(7) = 0 + 2 + 4 - 6 - 8 + 10 + 12 - 14 = 0;
a(8) = 0 + 2 + 4 - 6 - 8 + 10 + 12 - 14 - 16 = -16;
a(9) = 0 + 2 + 4 - 6 - 8 + 10 + 12 - 14 - 16 + 18 = 2, etc.
		

Crossrefs

Programs

  • Magma
    &cat [[-8*n,2,8*n+6,0]: n in [0..20]]; // Bruno Berselli, Jan 19 2016
  • Mathematica
    Table[Sum[(2k)*(-1)^((-sin((Pi k)/2)+cos((Pi k)/2)+1)/2), {k, 0, n}], {n, 0, 80}]
    CoefficientList[Series[2 x (x^2 - 2 x - 1) / ((x - 1) (x^2 + 1)^2), {x, 0, 100}], x] (* Vincenzo Librandi, Jan 13 2016 *)
    Table[1 - (-1)^(n (n + 1)/2) - (1 + (-1)^n) (-1)^(n/2) n, {n, 0, 80}] (* Bruno Berselli, Jan 19 2016 *)
  • PARI
    concat(0, Vec(2*x*(1+2*x-x^2)/((1-x)*(1+x^2)^2) + O(x^100))) \\ Michel Marcus, Jan 13 2016
    

Formula

G.f.: 2*x*(1 + 2*x - x^2)/((1 - x)*(1 + x^2)^2).
a(n) = Sum_{k = 0..n} (2k)*(-1)^((-sin((Pi*k)/2) + cos((Pi*k)/2) + 1)/2).
a(n) = Sum_{k = 0..n} A005843(k)*(-1)^A133872(k + 1).
a(n) = 1 - (-1)^(n*(n+1)/2) - (1+(-1)^n)*(-1)^(n/2)*n. [Bruno Berselli, Jan 19 2016]
Showing 1-3 of 3 results.