OFFSET
1,1
LINKS
Pierre CAMI, Table of n, a(n) for n = 1..30000
EXAMPLE
5 - 2 = 3 prime, 5 prime, 5*(5-1) - 1 = 19 prime, 5*(5-1) + 1 = 21 composite, so 5 is not in the sequence.
7 - 2 = 5 prime, 7 prime, 7*(7-1) - 1 = 41 prime, 7*(7-1) + 1 = 43 prime so 7 is in the sequence.
MATHEMATICA
Select[Prime[Range[100]], Union[PrimeQ[{# - 2, #^2 - # - 1, #^2 - # + 1}]] == {True} &] (* Alonso del Arte, Jun 27 2016 *)
Select[Prime[Range[17000]], AllTrue[{#-2, #^2-#-1, #^2-#+1}, PrimeQ]&] (* Harvey P. Dale, Jun 20 2024 *)
PROG
(PFGW & SCRIPT) twin.txt file with the smallest of twin pairs.
SCRIPT
DIM n
OPENFILEIN maf, twin.txt
OPENFILEOUT myf, a.txt
LABEL loop
GETNEXT n, maf
SET n, n+2
SET m, n*(n-1)-1
PRP m
IF ISPRP THEN GOTO a
GOTO loop
LABEL a
PRP m+2
IF ISPRP THEN WRITE myf, n
GOTO loop
(PARI) lista(nn) = forprime(p=2, nn, if (isprime(p-2) && isprime(p^2-p-1) && isprime(p^2-p+1), print1(p, ", "))); \\ Michel Marcus, Jul 07 2016
(Python)
from sympy import isprime, primerange
def aupto(n):
t = []
for p in primerange(2, n+1):
if isprime(p-2) and isprime(p**2 - p - 1) and isprime(p**2 - p + 1):
t.append(p)
return t # Paul Muljadi, Jun 21 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Pierre CAMI, Jun 27 2016
STATUS
approved