login
Prime numbers P such that 8*P^2-1 is also prime.
4

%I #19 Sep 08 2022 08:46:09

%S 2,3,5,11,17,19,23,31,59,67,79,89,103,107,137,173,193,229,233,241,257,

%T 263,271,311,317,353,359,383,409,431,479,509,521,523,541,563,569,577,

%U 593,599,613,641,709,739,751,787,829,887,907,919,947,971,983,1033

%N Prime numbers P such that 8*P^2-1 is also prime.

%H Pierre CAMI, <a href="/A245639/b245639.txt">Table of n, a(n) for n = 1..10000</a>

%e 8*2^2-1=31 prime so a(1)=2.

%e 8*3^2-1=71 prime so a(2)=3.

%e 8*5^2-1=199 prime so a(3)=5.

%e 8*7^2-1=391 composite.

%e 8*11^2-1=967 prime so a(4)=11.

%t Reap[Do[p = Prime[n]; If[PrimeQ[8*p^2-1], Sow[p]], {n, 1, 200}]][[2, 1]] (* _Jean-François Alcover_, Jul 28 2014 *)

%t Select[Prime[Range[200]], PrimeQ[8 #^2 - 1] &] (* _Vincenzo Librandi_, Sep 07 2014 *)

%o (PFGW & SCRIPT)

%o SCRIPT

%o DIM n,0

%o DIMS t

%o OPENFILEOUT myf,a(n).txt

%o LABEL loop1

%o SET n,n+1

%o SETS t,%d,%d\,;n;p(n)

%o PRP 8*p(n)^2-1,t

%o IF ISPRP THEN GOTO a

%o GOTO loop1

%o LABEL a

%o WRITE myf,t

%o GOTO loop1

%o (PARI) select(p->isprime(8*p^2-1), primes(300)) \\ _Colin Barker_, Jul 28 2014

%o (Python)

%o import sympy

%o from sympy import isprime

%o from sympy import prime

%o for n in range(1,10**3):

%o ..p = prime(n)

%o ..if isprime(8*p**2-1):

%o ....print(p,end=', ')

%o # _Derek Orr_, Aug 13 2014

%o (Magma) [p: p in PrimesUpTo(1500)| IsPrime(8*p^2-1)]; // _Vincenzo Librandi_, Sep 07 2014

%Y Cf. A245640, A245641, A245642, A245643.

%K nonn,easy

%O 1,1

%A _Pierre CAMI_, Jul 28 2014