A probable prime is a number that passes a test that all primes pass and that most composite numbers fail. Specifically, a Fermat probable prime is a number that passes Fermat’s primality test. Fermat’s test is the most commonly used, so that’s nearly always what anyone means by probable prime unless they’re more specific.
A number n is a Fermat probable prime for base b if
b^{n1} = 1 (mod n).
This test isn’t conclusive, but it can be implemented efficiently and it weeds out most composite numbers. To read more on probable primes, see this post.
If a number is a probable prime, how probable is it that it really is prime? This post will briefly summarize some results from a paper [1] that makes this precise. From that paper:
… let P(x) denote the probability that an integer n is composite given that

 n is chosen at random with 1 < n ≤ x, n odd,
 b is chosen at random with 1 < b < n − 1, and
 n is a probable prime to the base b.
The authors give upper bounds on P(x) for x equal to various powers of 2. In particular they report
P(2^{250}) ≤ 5.876 × 10^{−6}
and
P(2^{260}) ≤ 3.412 × 10^{−6}
and so the chances that a 256bit probable prime is composite are in the neighborhood of 4 in a million. In practice, one would test with multiple b‘s. The tests for various b‘s aren’t entirely independent, but running the tests for multiple bases does mean that fewer composite numbers slip through. There are a few pesky numbers, the Carmichael numbers, that are Fermat probable primes for nearly all bases (see footnote [2] here for more details), but these are rare.
I looked through the paper for results for larger powers of 2 to get results that would be applicable to, for example, RSA keys. The largest result explicit in the paper is
P(2^{330}) ≤ 8.713 × 10^{−8}
though I would like to know P(2^{1024}) and P(2^{1536}) since RSA keys are the products of (probable) primes this large. Presumably the results in [1] could be used to compute P(x) for larger values of x, but I haven’t read the paper closely enough to how much personal effort or computational effort that would require. I imagine it would be difficult or else the authors would have reported results for probable primes of the size frequently used in applications.
Related posts
[1] Jared Ducker Lichtman and Carl Pomerance. Improved error bounds for the Fermat primality test on random inputs. Mathematics of Computation. Volume 87, Number 314, November 2018, pages 2871–2890.
Each of BiEntropy and TriEntropy give a number between zero and one reflecting the approximate probability that a number represented in Binary or Trinary respectively should be prime based purely upon the periodicity of their digits.
See https://www.mdpi.com/10994300/22/3/311
Dear John:
Programs here at Linux Mansions are looking for 19,000 long decimal primes. A month or so of computation (using the gmp package) has found around 500 primes, but of that 500 none are “safe” (according to gmp).
*
So….not being a mathematician….I’ve started to wonder if the density of safe primes — 19,000 decimals long — is close to zero. I need a few of them to implement a private Diffie/Hellman scheme. Any thoughts?
Sean, I wrote a post to answer your question.
https://www.johndcook.com/blog/2023/04/10/densityofsafeprimes/
Thanks for bringing this up.
John:
No one on the interweb replies……except you!! Thank you so much!!
My interest in 19,000 long primes (i.e. approximately 60,000 bits) comes because of a programming project to create a (perhaps) secure Diffie/Hellman application. Your analysis (one in a billion Sophie Germain primes are “safe”) means that my C programs searching approximately ten million candidates in a month looks pretty futile!! Moving on…….do you have any observations about elliptical curves?
Thanks again!