Menu

Testing Methods

Jaska Börner

As of IsItPrime 1.6.0, there are several ways to test any given number.

As of version 1.7.0, these methods have been both expanded and improved.

Brute-Force Trial Division, or BFTD, is the slowest and most accurate method of testing for prime numbers. It does exactly what it sounds like it does - divides the candidate number by every number possible, starting at 2 and working up until it reaches the candidate number itself. This is great for most numbers, but past a certain size, BFTD is far too inefficient.

Small Prime Array Testing, or SPAT, is fast and inaccurate - however, it is good for determining very quickly if a number has small factors. It tests only prime factors, as those are statistically the most likely to occur in composite numbers. However, it should not be used to determine primality in an absolute sense, as most numbers reported as "prime" by SPAT are in fact false-positives.

In addition to these two main methods, there are two testing modes - verbose and non-verbose. Verbose mode displays all factors found for the number, whereas non-verbose mode stops after finding only one.

This is helpful if your primary goal is to factor a number you know to be composite. It also helps enforce compositeness by finding and displaying the same factor twice (a and quotient b, then b and quotient a).

There are also two testing ranges - up to n (up to the candidate number) and up to the square root of n.

The testing methods available in version 1.7.0 are as follows:

  • BFTD, up to n, verbose mode
  • BFTD, up to n, non-verbose mode
  • BFTD, up to sqrt, verbose mode
  • BFTD, up to sqrt, non-verbose mode
  • SPAT, up to first 100 primes, verbose mode
  • SPAT, up to first 500 primes, verbose mode

Most of these are triple-threaded. This makes the tests faster but also considerably more CPU-intensive. Please bear this in mind!