cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A242517 List of primes p for which p^n - 2 is prime for n = 1, 3, and 5.

This page as a plain text file.
%I A242517 #26 May 22 2025 10:21:37
%S A242517 31,619,2791,4801,15331,33829,40129,63421,69151,98731,127291,142789,
%T A242517 143569,149971,151849,176599,184969,201829,210601,225289,231841,
%U A242517 243589,250951,271279,273271,277549,280591,392269,405439,441799,472711,510709,530599,568441,578689
%N A242517 List of primes p for which p^n - 2 is prime for n = 1, 3, and 5.
%H A242517 Amiram Eldar, <a href="/A242517/b242517.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..250 from Abhiram R Devesh)
%e A242517 31 is in the sequence because
%e A242517 p = 31 (prime),
%e A242517 p - 2 = 29 (prime),
%e A242517 p^3 - 2 = 29789 (prime), and
%e A242517 p^5 - 2 = 28629149 (prime).
%t A242517 Select[Range[600000], PrimeQ[#] && AllTrue[#^{1, 3, 5} - 2, PrimeQ] &] (* _Amiram Eldar_, Apr 06 2020 *)
%o A242517 (Python)
%o A242517 import sympy
%o A242517 n=2
%o A242517 while n>1:
%o A242517     n1=n-2
%o A242517     n2=((n**3)-2)
%o A242517     n3=((n**5)-2)
%o A242517     ##Check if n1, n2 and n3 are also primes.
%o A242517     if sympy.ntheory.isprime(n1)== True and sympy.ntheory.isprime(n2)== True and sympy.ntheory.isprime(n3)== True:
%o A242517         print(n, " , " , n1, " , ", n2, " , ", n3)
%o A242517     n=sympy.ntheory.nextprime(n)
%o A242517 (PARI) isok(p) = isprime(p) && isprime(p-2) && isprime(p^3-2) && isprime(p^5-2); \\ _Michel Marcus_, Apr 06 2020
%o A242517 (PARI) list(lim)=my(v=List(),p=29); forprime(q=31,lim, if(q-p==2 && isprime(q^3-2) && isprime(q^5-2), listput(v,q)); p=q); Vec(v) \\ _Charles R Greathouse IV_, Apr 06 2020
%Y A242517 Intersection of A006512, A178251 and A154834, hence, intersection of A240126 and A154834.
%Y A242517 Cf. A001359.
%K A242517 nonn,easy
%O A242517 1,1
%A A242517 _Abhiram R Devesh_, May 17 2014