login
A279931
The maximum length of a sequence of consecutive composite integers in the closed interval from n^2 to (n+1)^2.
1
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, 11, 17, 21, 11, 17, 33, 17, 11, 13, 19, 12, 15, 17, 21, 13, 23, 15, 21, 23, 21, 13, 13, 17, 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
OFFSET
2,1
COMMENTS
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.
LINKS
Eric Weisstein's World of Mathematics, Legendre's Conjecture
EXAMPLE
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.
MAPLE
RunsOfOnes:=proc(L)
local j, r, i, k;
j:=1:
r[j]:=L[1]:
for i from 2 to nops(L) do
if L[i]=L[i-1] then r[j]:=r[j], L[i]; else
j:=j+1;
r[j]:=L[i];
fi;
od;
j;
[seq([r[k]], k=1..j)];
select(has, %, 1);
end proc:
f:=proc(n)
if isprime(n) then return 0; else return 1; fi;
end proc:
a:=proc(n)
local i;
[seq(i, i=n^2..(n+1)^2)];
map(f, %);
RunsOfOnes(%);
map(nops, %);
max(op(%));
end proc:
seq(a(n), n=2..100);
# second Maple program:
a:= proc(n) local i, maxsofar, scanmax;
maxsofar, scanmax:= 0, 0;
for i from n^2 to (n+1)^2 do
if isprime(i)
then scanmax:= 0
else scanmax:= scanmax+1;
maxsofar:= max(scanmax, maxsofar)
fi
od; maxsofar
end:
seq(a(n), n=2..100); # Alois P. Heinz, Apr 20 2017
MATHEMATICA
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 *)
max[n_]:=Max[Length/@Split[Select[Range[n^2, (n+1)^2], CompositeQ], #2-#1==1&]];
max/@Range[2, 100] (* Ivan N. Ianakiev, Apr 21 2017 *)
CROSSREFS
Cf. A014085 (number of primes between n^2 and (n+1)^2).
Sequence in context: A020483 A119912 A076368 * A071049 A171637 A140187
KEYWORD
nonn
AUTHOR
W. Edwin Clark, Apr 12 2017
STATUS
approved