NoPrimeTest

Files CCore/inc/math/NoPrimeTest.h CCore/src/math/NoPrimeTest.cpp

NoPrimeTest is a fast test for non-primality.


template <class Integer>
struct NoPrimeTest
 {
  ....

  template <class Random>
  static bool RandomTest(Integer P,ulen count,Random &random);
 };

The template parameter is an Integer type.

RandomTest() tests the given integer P. It returns true, if P is probably prime. If the return value is false, then P is not prime. RandomTest() does count of randomly chosen subtests to find out, that P is not prime. Each subtest has a chance above 50% to fail, if P is not prime. The more count, the more chances to break a non-prime number. The practical range for count is 30-100. random is a Random class.