OFFSET
0,6
LINKS
Robert Israel and Paul Nanninga, Table of n, a(n) for n = 0..10000 (terms up to a(100) from Paul Nanninga)
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.
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 *)
PROG
(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
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Rudi Huysmans (rudi.huysmans(AT)pandora.be), Sep 18 2002
STATUS
approved