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.

A357746 Primes p such that the least k for which k*p + 1 is prime is also the least k for which k*p - 1 is prime.

This page as a plain text file.
%I A357746 #16 Jan 02 2023 15:26:50
%S A357746 47,103,107,283,313,347,397,773,787,907,1051,1117,1319,1433,1823,2027,
%T A357746 2153,2203,2287,2333,2347,2381,2909,3221,3257,3673,3923,3929,4129,
%U A357746 4153,4217,4547,4597,4657,4721,4969,5023,5387,5407,5693,5717,5827,5881,6373,6781,6863,6997
%N A357746 Primes p such that the least k for which k*p + 1 is prime is also the least k for which k*p - 1 is prime.
%C A357746 If A035096(n) = A216568(n) the n-th prime is a term. Here k*p must be the composite number sandwiched between a pair of twin primes, so by Wilson's theorem, k must be a multiple of 6.
%H A357746 Karl-Heinz Hofmann, <a href="/A357746/b357746.txt">Table of n, a(n) for n = 1..10000</a>
%H A357746 Wikipedia, <a href="https://en.wikipedia.org/wiki/Wilson%27s_theorem">Wilson's theorem</a>.
%e A357746 a(1) = 47: 47*6 + 1 = 283 (a prime), 47*6 - 1 = 281 (also a prime), and no k < 6 gives a prime as the result for both formulas.
%t A357746 q[p_] := Module[{k = 1, r}, While[! Or @@ (r = PrimeQ[k*p + {-1, 1}]), k++]; And @@ r]; Select[Prime[Range[900]], q] (* _Amiram Eldar_, Jan 01 2023 *)
%o A357746 (Python)
%o A357746 from sympy import sieve, isprime
%o A357746 def leastk(p, plusminus):
%o A357746     k=1
%o A357746     while not isprime(k * p + plusminus): k += 1
%o A357746     return k
%o A357746 print([p for p in sieve[1:1000] if leastk(p, 1) == leastk(p, -1)])
%o A357746 (PARI) isk(p, x) = my(k=1); while (!isprime(k*p+x), k++); k;
%o A357746 isok(p) = if (isprime(p), isk(p, +1) == isk(p, -1)); \\ _Michel Marcus_, Jan 01 2023
%Y A357746 Cf. A000040, A014574, A001359, A006512, A035096, A216568.
%K A357746 nonn
%O A357746 1,1
%A A357746 _Karl-Heinz Hofmann_, Jan 01 2023