Skip to content
IntIsProbablePrimeWithError

IntIsProbablePrimeWithError

Description

Perform a probabilistic primality test.

This is a probable-prime test, not a proof of primality.

Parameters

Name Direction Description
value in Integer to test
error out Optional error flag set to true when the test cannot be completed.

Usage example (from documentation)

  bool prime = IntIsProbablePrime(&value);

Success

Returns true when the value is probably prime.

Failure

Returns false otherwise.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    bool IntIsProbablePrimeWithError(Int *value, bool *error) {
        static const u64 bases[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
        }
    
        while (!IntIsProbablePrimeWithError(&candidate, &error)) {
            if (error) {
                IntDeinit(&candidate);
    
        static inline bool int_is_probable_prime_no_error(Int *value) {
            return IntIsProbablePrimeWithError(value, NULL);
        }
    ///
    #define IntIsProbablePrime(...)                                                                                        \
        INT_IS_PROBABLE_PRIME_SELECT(__VA_ARGS__, IntIsProbablePrimeWithError, int_is_probable_prime_no_error)(__VA_ARGS__)
    
    #ifndef __cplusplus
Last updated on