login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A230546
Least positive integer k <= n such that 2*k^2-1 is a prime and n - k is a square, or 0 if such an integer k does not exist.
1
0, 2, 2, 3, 4, 2, 3, 4, 8, 6, 2, 3, 4, 10, 6, 7, 8, 2, 3, 4, 17, 6, 7, 8, 21, 10, 2, 3, 4, 21, 6, 7, 8, 18, 10, 11, 21, 2, 3, 4, 25, 6, 7, 8, 36, 10, 11, 39, 13, 25, 2, 3, 4, 18, 6, 7, 8, 22, 10, 11
OFFSET
1,2
COMMENTS
By the conjecture in A230494, we should have a(n) > 0 for all n > 1.
EXAMPLE
a(4) = 3 since neither 4 - 1 = 3 nor 4 - 2 = 2 is a square, but 4 - 3 = 1 is a square and 2*3^2 - 1 = 17 is a prime.
MATHEMATICA
SQ[n_]:=IntegerQ[Sqrt[n]]
Do[Do[If[PrimeQ[2k^2-1]&&SQ[n-k], Print[n, " ", k]; Goto[aa]], {k, 1, n}];
Print[n, " ", 0]; Label[aa]; Continue, {n, 1, 60}]
lpik[n_]:=Module[{k=1}, While[!PrimeQ[2k^2-1]||!IntegerQ[Sqrt[n-k]], k++]; k]; Join[{0}, Array[lpik, 60, 2]] (* Harvey P. Dale, Aug 04 2021 *)
KEYWORD
nonn
AUTHOR
Zhi-Wei Sun, Oct 23 2013
STATUS
approved