%I #34 Apr 21 2017 12:52:56
%S 2,3,3,5,3,5,5,7,8,6,5,9,11,9,6,13,9,7,9,11,11,12,9,11,9,11,11,13,9,
%T 11,17,21,11,17,33,17,11,13,19,12,15,17,21,13,23,15,21,23,21,13,13,17,
%U 27,19,25,27,19,11,15,21,19,21,23,29,17,23,17,29,15,27,23,29,31,27,19,27,23,11,29,17,23,29,23,29,17,19,29,29,23,29,33,19,29,23,21,35,21,27,27
%N The maximum length of a sequence of consecutive composite integers in the closed interval from n^2 to (n+1)^2.
%C Suggested by Legendre's conjecture (still open) that for n > 0 there is always a prime between n^2 and (n+1)^2 and mentioned to the author by Jack Laffan.
%H Vaclav Kotesovec, <a href="/A279931/b279931.txt">Table of n, a(n) for n = 2..10000</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/LegendresConjecture.html">Legendre's Conjecture</a>
%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Legendre%27s_conjecture">Legendre's conjecture</a>
%e a(3) = 3 since the longest sequence of consecutive primes in [9, 10, 11, 12, 13, 14, 15, 16] is the length three sequence 14, 15, 16.
%p RunsOfOnes:=proc(L)
%p local j,r,i,k;
%p j:=1:
%p r[j]:=L[1]:
%p for i from 2 to nops(L) do
%p if L[i]=L[i-1] then r[j]:=r[j],L[i]; else
%p j:=j+1;
%p r[j]:=L[i];
%p fi;
%p od;
%p j;
%p [seq([r[k]], k=1..j)];
%p select(has,%,1);
%p end proc:
%p f:=proc(n)
%p if isprime(n) then return 0; else return 1; fi;
%p end proc:
%p a:=proc(n)
%p local i;
%p [seq(i,i=n^2..(n+1)^2)];
%p map(f,%);
%p RunsOfOnes(%);
%p map(nops,%);
%p max(op(%));
%p end proc:
%p seq(a(n), n=2..100);
%p # second Maple program:
%p a:= proc(n) local i, maxsofar, scanmax;
%p maxsofar, scanmax:= 0, 0;
%p for i from n^2 to (n+1)^2 do
%p if isprime(i)
%p then scanmax:= 0
%p else scanmax:= scanmax+1;
%p maxsofar:= max(scanmax, maxsofar)
%p fi
%p od; maxsofar
%p end:
%p seq(a(n), n=2..100); # _Alois P. Heinz_, Apr 20 2017
%t Table[s=0; smax=0; Do[If[PrimeQ[j], If[s>smax, smax=s]; s=0, s++], {j, n^2, (n+1)^2}]; If[s>smax, smax=s]; smax, {n, 2, 100}] (* _Vaclav Kotesovec_, Apr 20 2017 *)
%t max[n_]:=Max[Length/@Split[Select[Range[n^2,(n+1)^2],CompositeQ],#2-#1==1&]];
%t max/@Range[2,100] (* _Ivan N. Ianakiev_, Apr 21 2017 *)
%Y Cf. A014085 (number of primes between n^2 and (n+1)^2).
%K nonn
%O 2,1
%A _W. Edwin Clark_, Apr 12 2017