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.

A074239 Related to cumulative number of non-twin primes.

Original entry on oeis.org

0, 0, 0, 1, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 11, 12, 13, 14, 15, 16, 16, 17, 17, 18, 19, 20, 21, 21, 22, 22, 23, 24, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31, 32, 32, 33, 34, 34, 35, 36, 37, 38, 38, 39, 40, 40, 41, 42, 43, 43, 44, 45, 46, 47, 47, 48, 49, 50
Offset: 0

Views

Author

Rudi Huysmans (rudi.huysmans(AT)pandora.be), Sep 18 2002

Keywords

Crossrefs

Cf. A065091 (odd primes), A007510 (non-twin primes).

Programs

  • Maple
    N:= 100: # to get a(0) to a(N)
    P:= [seq(ithprime(i),i=2..N+2)]:
    ListTools:-PartialSums([0,seq(`if`(P[i]-P[i-1]=2,0,1),i=2..N+1)]); # Robert Israel, May 13 2016
  • Mathematica
    Accumulate@ Table[If[Prime@ n - Prime[n - 1] == 2, 0, 1], {n, 2, 120}] - 1 (* Michael De Vlieger, May 13 2016, after Robert Israel *)
  • PARI
    op(n) = prime(n+1);
    lista(nn) = {my(x=0); for (n=1, nn, print1(x, ", "); if ((op(n+1) - op(n)) > 2, x++););} \\ Michel Marcus, May 13 2016

Formula

Take the sequence of odd primes op(n); set a(0) = 0; if op(n+1)-op(n)=2 a(n+1) = a(n), if op(n+1)-op(n) > 2 a(n+1) = a(n) + 1.