OFFSET
0,1
COMMENTS
A contiguous sequence of numbers satisfying the pattern sf sf nsf sf ... nsf sf nsf sf sf with k+1 nsf numbers alternating with k sf numbers that are bounded by a pair of sf numbers at both ends is called an isolated alternating nsf/sf run of size k. The left sf bounding number is the start of the run.
Any such run must start at an even number i and have an even size j, since for i odd i+3 is nsf, and for i even and j odd i+2*j+4 is nsf.
For all n>=0, a(n)+2 is divisible by 4.
a(4) > 5*10^9
EXAMPLE
a(0) = 2 since 2, 3, 5 and 6 are sf while 4 is nsf.
a(2) = 482 since in the interval 482...494 the nsf/sf pattern is sf sf nsf sf nsf sf nsf sf nsf sf nsf sf sf and it is the first occurrence of that 13-number run.
MATHEMATICA
nsfRun[n_] := Module[{i=n}, While[!SquareFreeQ[i], i++]; i-n]
sfRun[n_] := Module[{i=n}, While[SquareFreeQ[i], i++]; i-n]
sfBlockSearch[i_] := Module[{searching=True, j=i, r, s}, While[searching, r=nsfRun[j]; s=sfRun[j+r]; If[s<2, j+=r+s, searching=False]]; j+r+s]
nsfsfPairQ[i_] := nsfRun[i]==1 && sfRun[i+1]==1
nsfsfEndQ[i_] := nsfRun[i]==1 && sfRun[i+1]>1
nsfsfRun[i_] := Module[{searching=True, count, j=i, s, e}, j=sfBlockSearch[j]; While[searching, count=0; s=j; While[nsfsfPairQ[j], count++; j+=2]; e=j; If[count==0 || !nsfsfEndQ[j], j=sfBlockSearch[j], searching=False]]; {s, e, count}]
a271145[{low_, high_}, b_] := Module[{i=low, k, k3, list=Table[{}, b]}, While[i<=high, k=nsfsfRun[i]; k3=Last[k]/2; If[list[[k3]]=={}, list[[k3]]=k[[1]]-2]; i=k[[2]]]; list]
a271145[{0, 10000}, 3] (* computes a(1), a(2), a(3) *)
CROSSREFS
KEYWORD
nonn,more
AUTHOR
Hartmut F. W. Hoft, Mar 31 2016
STATUS
approved