OFFSET
1,1
COMMENTS
A zigzag of a function f(n) is a run of consecutive strict local extrema.
EXAMPLE
f(11),f(12),...,f(15) are: 6, 4, 2, 4, 6. Note that a zigzag of length 1 occurs at f(13)=2. This is a maximal zigzag, since neither f(12)=4 nor f(14)=4 are local extrema of f. Also, a maximal zigzag of length 1 first occurs at f(13). Therefore a(1) = 13.
MATHEMATICA
f[n_] := Prime[n+1]-Prime[n]; e[n_] := (f[n]-f[n-1])(f[n]-f[n+1])>0; For[n=1, n<100, n++, a[n]=0]; For[k=4; l=0, True, k++, If[e[k], l++, If[a[l]===0, Print["a(", l, ")=", a[l]=k-l]]; l=0]]
CROSSREFS
KEYWORD
nonn
AUTHOR
Joseph L. Pe, Jan 23 2002
EXTENSIONS
Edited by Dean Hickerson, Jun 26 2002
STATUS
approved