Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compute one or more safe primes in a requested range
ResourceFunction["RandomSafePrime"][max] gives a safe prime equal or less than max. | |
ResourceFunction["RandomSafePrime"][{min,max}] gives a safe prime in the range min to max. | |
ResourceFunction["RandomSafePrime"][range,n] gives n safe primes in the specified range. |
Generate a random safe prime:
In[1]:= |
Out[1]= |
Check that it is indeed a safe prime using the resource function SafePrimeQ:
In[2]:= |
Out[2]= |
Generate several safe primes:
In[3]:= |
Out[3]= |
Check that they are safe primes via the resource function SafePrimeQ:
In[4]:= |
Out[4]= |
Generate a safe prime in a specific range:
In[5]:= |
Out[5]= |
Generate several safe primes in a specific range:
In[6]:= |
Out[6]= |
Attempting to generate a large number of safe primes in a small amount of time will time out:
In[7]:= |
Out[7]= |
This work is licensed under a Creative Commons Attribution 4.0 International License