login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A237710
Least prime p < n with pi(n-p) a square, or 0 if such a prime p does not exist.
5
0, 0, 2, 2, 3, 5, 5, 7, 2, 2, 2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11, 13, 13, 17, 2, 2, 2, 2, 2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11, 13, 13, 17, 17, 17, 17, 19, 19, 23, 23, 23, 23, 29, 29, 29, 2, 2, 2, 2, 2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11, 13
OFFSET
1,3
COMMENTS
According to the conjecture in A237706, a(n) should be positive for all n > 2.
LINKS
EXAMPLE
a(5) = 3 since pi(5-3) = 1^2, but pi(5-2) = 2 is not a square.
MATHEMATICA
SQ[n_]:=IntegerQ[Sqrt[n]]
q[n_]:=SQ[PrimePi[n]]
Do[Do[If[q[n-Prime[k]], Print[n, " ", Prime[k]]; Goto[aa]], {k, 1, PrimePi[n-1]}];
Print[n, " ", 0]; Label[aa]; Continue, {n, 1, 100}]
lp[n_]:=Module[{p=2}, While[!IntegerQ[Sqrt[PrimePi[n-p]]], p=NextPrime[p]]; p]; Join[{0, 0}, Array[ lp, 80, 3]] (* Harvey P. Dale, Jan 28 2024 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Zhi-Wei Sun, Feb 12 2014
STATUS
approved