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.

A181482 The sum of the first n integers, with every third integer taken negative.

Original entry on oeis.org

1, 3, 0, 4, 9, 3, 10, 18, 9, 19, 30, 18, 31, 45, 30, 46, 63, 45, 64, 84, 63, 85, 108, 84, 109, 135, 108, 136, 165, 135, 166, 198, 165, 199, 234, 198, 235, 273, 234, 274, 315, 273, 316, 360, 315, 361, 408, 360, 409, 459, 408, 460, 513, 459, 514, 570, 513, 571, 630
Offset: 1

Views

Author

Jon Perry, Oct 23 2010

Keywords

Comments

The partial sum for the first 10^k terms are 76, 57256, 55722556, 55572225556, 55557222255556,..., i.e., the palindrome 5{k}2{k-1}5{k} plus 1+2*10^(2*k-1). - R. J. Cano, Mar 10 2013, edited by M. F. Hasler, Mar 25 2013

Examples

			a(7) = 1 + 2 - 3 + 4 + 5 - 6 + 7 = 10.
		

Crossrefs

Programs

  • Haskell
    a181482 n = a181482_list !! (n-1)
    a181482_list = scanl1 (+) $ zipWith (*) [1..] $ cycle [1, 1, -1]
    -- Reinhard Zumkeller, Nov 23 2014
  • JavaScript
    c = 0; for (i = 1; i < 100; i++) {c += Math.pow(-1, (i + 1) % 3)*i; document.write(c, ", ");} // Jon Perry, Feb 17 2013
    
  • JavaScript
    c=0; for (i = 1; i < 100; i++) { c += (1 - (i + 1) % 3 % 2 * 2) * i; document.write(c + ", "); } // Jon Perry, Mar 03 2013
    
  • Magma
    I:=[1,3,0,4,9,3,10]; [n le 7 select I[n] else Self(n-1)+2*Self(n-3)-2*Self(n-4)-Self(n-6)+Self(n-7): n in [1..60]]; // Vincenzo Librandi, Feb 17 2013
    
  • Mathematica
    a[n_] := Sum[If[Mod[j, 3] == 0, -j, j], {j, 1, n}]; Table[a[i], {i, 1, 50, 1}] (* Jon Perry *)
    tri[n_] := n (n + 1)/2; f[n_] := tri@ n - 6 tri@ Floor[n/3]; Array[f, 63] (* Robert G. Wilson v, Oct 24 2010 *)
    CoefficientList[Series[-(1 + 2*x + 2*x^3 + x^4 - 3*x^2)/((1 + x + x^2)^2*(x - 1)^3), {x, 0,30}], x] (* Vincenzo Librandi, Feb 17 2013 *)
    Table[Sum[k * (-1)^Boole[Mod[k, 3] == 0], {k, n}], {n, 60}] (* Alonso del Arte, Feb 24 2013 *)
    With[{nn=20},Accumulate[Times@@@Partition[Riffle[Range[3nn],{1,1,-1}],2]]] (* Harvey P. Dale, Feb 09 2015 *)
  • PARI
    a(n)=sum(k=1,n,k*((-1)^(k%3==0)) )  \\ R. J. Cano, Feb 26 2013
    
  • PARI
    a(n)={my(y=n\3);n*(n+1)\2-3*y*(y+1)} \\ R. J. Cano, Feb 28 2013
    

Formula

From R. J. Mathar, Oct 23 2010: (Start)
a(n) = a(n-1) + 2*a(n-3) - 2*a(n-4) - a(n-6) + a(n-7).
G.f.: -x*(1+2*x+2*x^3+x^4-3*x^2) / ( (1+x+x^2)^2*(x-1)^3 ).
a(n) = 2*A061347(n+1)/9 +4/9 + n*(n+1)/6 + 2*b(n)/3 where b(3k+1) = 0, b(3k) = -3k - 1 and b(3k+2) = 3k + 3. (End)
a(n) = sum((i+1)*A131561(i), i=0..n-1) = A000217(n)-6*A000217(floor(n/3)). [Bruno Berselli, Dec 10 2010]
a(0) = 0, a(n) = a(n-1) + (-1)^((n + 1) mod 3)*n - Jon Perry, Feb 17 2013
a(n) = n*(n+1)/2-3*floor(n/3)*(floor(n/3)+1). - R. J. Cano, Mar 01 2013 [Same as Berselli's formula. - Ed.]
a(3k) = 3k(k-1)/2. - Jon Perry, Mar 01 2013
a(0) = 0, a(n) = a(n-1) + (1 - ((n+1) mod 3 mod 2) * 2) * n. - Jon Perry, Mar 03 2013

Extensions

More terms added by R. J. Mathar, Oct 23 2010

A222739 Partial sums of the first 10^n terms in A181482.

Original entry on oeis.org

76, 57256, 55722556, 55572225556, 55557222255556, 55555722222555556, 55555572222225555556, 55555557222222255555556, 55555555722222222555555556, 55555555572222222225555555556, 55555555557222222222255555555556, 55555555555722222222222555555555556
Offset: 1

Views

Author

R. J. Cano, Mar 07 2013

Keywords

Comments

Indeed: a(n) is the sum of 2*10^(2n-1)+1 and the palindrome built by repetition of the digits 2 and 5 such that it recalls the number 525.
Let x = 10^n, y = floor(x/3), and B(n) = Sum_{k<=10^n} binomial(floor(k/3),2).
6*B(n) differs from a(n) by (x*(x+1)*(1+(2*x+1)/3))/4-3*y*(3*y+1).

Examples

			When n=1, 10^n is 10. By looking at A181482 for its first 10 terms we have the sum: 1+3+0+4+9+3+10+18+9+19, then a(1)=76.
		

Crossrefs

Programs

  • PARI
    repdigit(n,k)=(n!=0)*floor((10/9)*n*10^(k-1));
    palindrome(n)=repdigit(5,n)*10^(2*n-1)+repdigit(2,n-1)*10^n+repdigit(5,n);
    a(n)=palindrome(n)+(1+2*10^(2*n-1));
    
  • PARI
    Vec(-4*x*(250000*x^3-157875*x^2+6795*x-19)/((x-1)*(10*x-1)*(100*x-1)*(1000*x-1)) + O(x^100)) \\ Colin Barker, Oct 31 2015

Formula

a(n) = Sum_{k<=10^n} A181482(k).
From Colin Barker, Oct 31 2015: (Start)
a(n) = 1111*a(n-1)-112110*a(n-2)+1111000*a(n-3)-1000000*a(n-4) for n>4.
G.f.: -4*x*(250000*x^3-157875*x^2+6795*x-19) / ((x-1)*(10*x-1)*(100*x-1)*(1000*x-1)).
(End)

A243106 a(n) = Sum_{k=1..n} (-1)^isprime(k)*10^k.

Original entry on oeis.org

10, -90, -1090, 8910, -91090, 908910, -9091090, 90908910, 1090908910, 11090908910, -88909091090, 911090908910, -9088909091090, 90911090908910, 1090911090908910, 11090911090908910, -88909088909091090, 911090911090908910, -9088909088909091090
Offset: 1

Views

Author

R. J. Cano, Aug 19 2014

Keywords

Comments

Alternative definition: a(n,x)=T(x,1) for a dichromate or Tutte-Whitney polynomial in which the matrix t[i,j] is defined as t[i,j]=Delta(i,j)*((-1)^isprime(i)) and "Delta" is the Kronecker Delta function. - Michel Marcus, Aug 19 2014
If 10 is replaced by 1, then this becomes A097454. If it is replaced by 2, one gets A242002. Choosing powers of the base b=10, as done here, allows one to easily read off the equivalent for any other base b > 4, by simply replacing digits 8,9 with b-2,b-1 (when terms are written in base b). [Comment extended by M. F. Hasler, Aug 20 2014]
There are 2^n ways of taking the partial sum of the first n powers of b=10 if exponent zero is excluded and the signs can be assigned arbitrarily. Conjecture: When expressed in base b, the absolute value for any of these terms only contains digits belonging to {0,1,b-2,b-1}; here {0,1,8,9}.

Examples

			n=1 is not prime x^1 = (10)^1 = 10, therefore a(1)=10;
n=2 is prime and x^2 = (10)^2 = 100, taking it negative, a(2) = 10 - 100 = -90;
n=3 also is prime, x^3 = 1000, and we have a(3) = 10 - 100 - 1000 = -1090;
n=4 is not prime, so a(4) = 10 - 100 - 1000 + 10000 = 8910;
n=5 is prime, then a(5) = 10 - 100 - 1000 + 10000 - 100000 = -91090;
Examples of analysis for the concatenation patterns among the terms can be found at the "Additional Information" link.
		

Crossrefs

Cf. A097454.
The same kind of base-independent behavior: A215940, A217626.
Partial sums of alternating series: A181482, A222739, A213203.

Programs

  • Mathematica
    Table[Sum[ (-1)^Boole@ PrimeQ@ k*10^k, {k, n}], {n, 19}] (* Michael De Vlieger, Jan 03 2016 *)
  • PARI
    ap(n, x)={my(s); forprime(p=1, n, s+=x^p); s}
    a=(n, x=10)->(x^(n+1)-1)/(x-1)-2*ap(n, x)-1;
    
  • PARI
    Delta=(i, j)->(i==j); /* Kronecker's Delta function */
    t=n->matrix(n, n, i, j, Delta(i, j)*((-1)^isprime(i))); /* coeffs t[i, j] */
    /* Tutte polynomial over n */
    T(n, x, y)={my(t0=t(n)); sum(i=1, n, sum(j=1, n, t0[i, j]*(x^i)*(y^j)))};
    a=(n, x=10)->T(n, x, 1);
    
  • PARI
    A243106(n,b=10)=sum(k=1,n,(-1)^isprime(k)*b^k) \\ M. F. Hasler, Aug 20 2014

Formula

a(n,x) = Sum_{k=1..n} (-1)^isprime(k)*(x^k), for x=10 in decimal.

Extensions

Definition simplified by N. J. A. Sloane, Aug 19 2014
Definition further simplified and more terms from M. F. Hasler, Aug 20 2014
Showing 1-3 of 3 results.