%I #16 Jul 23 2021 10:42:06
%S 5,11,13,19,29,41,43,71,103,151,181,229,239,349,419,461,463,491,571,
%T 859,1069,1429,1483,1583,1721,2549,2969,3079,3191,3319,3331,4003,7177,
%U 7193,7309,7873,8009,8161,8849,9127,9283,10729,11779,13567,13693,15809,15959
%N Lesser of two consecutive primes p,q such that q^2 - p^2 + 1 = the square of a prime.
%C One could generate a larger sequence using any three primes p,q,r such that p^2 + 1 = q^2 + r^2. One could consider these "almost prime Pythagorean triangles."
%H Charles R Greathouse IV, <a href="/A157750/b157750.txt">Table of n, a(n) for n = 1..10000</a>
%e For the consecutive pair (19,23), 23^2 - 19^2 + 1 = 169 = 13^2; thus 19 is in the sequence.
%p a := proc (n) if isprime(sqrt(nextprime(ithprime(n))^2-ithprime(n)^2+1)) = true then ithprime(n) else end if end proc: seq(a(n), n = 1 .. 2000); # _Emeric Deutsch_, Mar 07 2009
%t ltcpQ[{a_,b_}]:=PrimeQ[Sqrt[b^2-a^2+1]]; Select[Partition[ Prime[ Range[ 2000]],2,1],ltcpQ][[All,1]] (* _Harvey P. Dale_, Jul 23 2021 *)
%o (PARI) list(lim)=my(v=List(),p=2,t); forprime(q=3,nextprime(lim\1+1), if(issquare(q^2-p^2+1,&t)&&isprime(t), listput(v, p)); p=q); Vec(v) \\ _Charles R Greathouse IV_, Jan 31 2017
%Y Cf. A001481.
%K nonn
%O 1,1
%A _J. M. Bergot_, Mar 05 2009
%E More terms from _Klaus Brockhaus_, Mar 05 2009
%E More terms from _Emeric Deutsch_, Mar 07 2009
|