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”).

A323741
a(n) = m-p where m = (2n+1)^2 and p is the largest prime < m.
1
2, 2, 2, 2, 8, 2, 2, 6, 2, 2, 6, 6, 2, 2, 8, 2, 2, 2, 10, 12, 2, 8, 2, 2, 8, 6, 2, 20, 12, 2, 2, 6, 6, 2, 2, 6, 2, 2, 12, 8, 6, 6, 8, 2, 8, 2, 12, 6, 10, 8, 2, 22, 2, 14, 20, 6, 6, 2, 2, 2, 8, 6, 2, 8, 2, 6, 2, 12, 2, 14, 6, 2, 8, 8, 14, 10, 2, 18, 20, 2, 8, 14, 6, 2, 10, 2, 32, 2, 12, 12, 2, 8, 6, 44, 2, 6, 14, 6, 20, 14
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
FORMULA
a(n) = A049711(A016754(n)).
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