Function Repository Resource:

StrongPrimeQ

Source Notebook

Determine whether a number is a strong prime

Contributed by: Arnoud Buzing

ResourceFunction["StrongPrimeQ"][p]

gives True if p is a strong prime and False otherwise.

Details and Options

ResourceFunction["StrongPrimeQ"] uses the number theoretic definition of a strong prime, not the cryptographic one.
A prime is strong if it is greater than the arithmetic average of its nearest primes above and below.

Examples

Basic Examples (4) 

The prime number 457 is strong:

In[1]:=
ResourceFunction["StrongPrimeQ"][457]
Out[1]=

To show this, we must show that 457 is bigger than the average of its preceding and succeeding primes. First, find the number of primes less than or equal to 457:

In[2]:=
PrimePi[457]
Out[2]=

Because 457 is the 88th prime, we consider the 87th and 89th primes:

In[3]:=
before = Prime[87]
Out[3]=
In[4]:=
after = Prime[89]
Out[4]=

Now, test that 457 is bigger than the average of these:

In[5]:=
457 > (before + after)/2
Out[5]=

Publisher

Arnoud Buzing

Version History

  • 1.0.0 – 29 April 2020

License Information