OFFSET
1,1
COMMENTS
a(n) cannot be a square: suppose a(n) = k^2; then p=m-a(n) could be factored as (2n+k-1)*(2n-k-1); hence it would not be a prime.
Legendre's conjecture implies a(n) <= 4*n. Oppermann's conjecture implies a(n) <= 2*n. - Robert Israel, Sep 04 2019
All terms are even. - Alois P. Heinz, Sep 04 2019
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
EXAMPLE
When n=4, m=81, p=79, so a(4) = 81-79 = 2.
MAPLE
seq((2*n+1)^2-prevprime((2*n+1)^2), n=1..100); # Robert Israel, Sep 04 2019
MATHEMATICA
mp[n_]:=Module[{m=(2n+1)^2}, m-NextPrime[m, -1]]; Array[mp, 100] (* Harvey P. Dale, Feb 03 2022 *)
PROG
(VBA/Excel)
Sub A323741()
For n = 1 To 100
Cells(n, 1) = (2 * n + 1) ^ 2
k = Cells(n, 1) - 2
k1 = (2 * n - 1) ^ 2 + 2
For p = k To k1 Step -2
IsPrime = True
For i = 2 To Int(Sqr(p))
If p mod i = 0 Then
IsPrime = False
Exit For
End If
Next i
If IsPrime Then
Cells(n, 2) = p
Cells(n, 3) = Cells(n, 1) - Cells(n, 2)
Exit For
End If
Next p
Next n
End Sub
(PARI) a(n) = (2*n+1)^2 - precprime((2*n+1)^2 - 1); \\ Michel Marcus, Sep 05 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Ali Sada, Sep 03 2019
STATUS
approved