%I #29 Sep 22 2024 17:58:29
%S 3,5,41,59,101,2729,3251,9719,11549,12251,19211,28619,41201,47711,
%T 49391,55439,58229,61979,63029,63311,79631,81371,85331,103391,122039,
%U 135719,153509,157349,164249,167441,178601,188861,197711,208001,209819,216779,219311,226451
%N Prime p such that p and p+2 are twin primes and p^2+p-1 p^2+p+1 are also twin primes.
%C Subsequence of A088483.
%H Pierre CAMI, <a href="/A228968/b228968.txt">Table of n, a(n) for n = 1..10000</a>
%e 3 and 5 twin primes as 3*3+3-1=11 and 13, a(2)=3.
%e 5 and 7 twin primes as 5*5+5-1=29 and 31, a(3)=5.
%t Select[Transpose[Select[Partition[Prime[Range[21000]],2,1],#[[2]]-#[[1]] == 2&]][[1]],AllTrue[ #^2+#+{1,-1},PrimeQ]&] (* The program uses the AllTrue function from Mathematica version 10 *) (* _Harvey P. Dale_, Nov 10 2014 *)
%o PFGW & SCRIPTIFY
%o SCRIPT
%o DIM n,0
%o DIM m
%o DIM k,0
%o DIMS ta
%o OPENFILEOUT myf,a(n).txt
%o OPENFILEIN maf,twin.txt
%o LABEL loop1
%o SET n,n+1
%o IF n>2999999 THEN END
%o GETNEXT m,maf
%o SETS ta,%d\,;n
%o PRP m^2+m-1,ta
%o IF ISPRP THEN GOTO a
%o GOTO loop1
%o LABEL a
%o PRP m^2+m+1,ta
%o IF ISPRP THEN GOTO b
%o GOTO loop1
%o LABEL b
%o WRITE myf,m
%o GOTO loop1
%o The file twin.txt has the first 3000000 of first of twin primes
%o (PFGW) ABC2 $a & $a+2 & $a^2+$a-1 & $a^2+$a+1
%o a: 1 to 3000000
%o _Charles R Greathouse IV_, Sep 10 2013
%o (PARI) is(n)=isprime(n)&&isprime(n+2)&&isprime(n^2+n-1)&&isprime(n^2+n+1) \\ _Charles R Greathouse IV_, Sep 10 2013
%o (Sage)
%o [x for x in primes_first_n(900) if x+2 in Primes() and x^2+x-1 in Primes() and x^2+x+1 in Primes()] #_Tom Edgar_, Sep 10 2013
%Y Cf. A088483.
%K nonn
%O 1,1
%A _Pierre CAMI_, Sep 10 2013