A271145 a(n) = k is the least number at which an isolated alternating run of nonsquarefree/squarefree (nsf/sf) numbers of size n starts.
2, 14, 482, 6346
Offset: 0
Examples
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.
Programs
-
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) *)
Comments