OFFSET
1,1
COMMENTS
Call a finite subsequence of consecutive terms of a(n) a "zigzag" if it consists of consecutive integers; for example, 30, 31, 32, 33, 34, 35 is a zigzag. Are there zigzags of arbitrary length? (Cf. A066918.)
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
4 is a term since f(4) is a local maximum: f(3)=2, f(4)=4, f(5)=2.
MAPLE
Primes:= select(isprime, [2, seq(2*i+1, i=1..10^3)]):
G:= Primes[2..-1] - Primes[1..-2]:
select(n -> G[n] > max(G[n-1], G[n+1]) or G[n] < min(G[n-1], G[n+1]), [$2..nops(G)-1]):
# Robert Israel, Sep 20 2015
MATHEMATICA
f[n_] := Prime[n+1]-Prime[n]; Select[Range[200], (f[ # ]-f[ #-1])(f[ # ]-f[ #+1])>0&]
PROG
(PARI) f(n) = prime(n+1)-prime(n);
isok(n) = if (n>2, my(x=f(n), y=f(n-1), z=f(n+1)); ((x>y) && (x>z)) || ((x<y) && (x<z))); \\ Michel Marcus, Mar 26 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Joseph L. Pe, Jan 02 2002
EXTENSIONS
Edited by Dean Hickerson, Jun 26 2002
STATUS
approved