Did you know ... Search Documentation: Pack nan_numerics_prime -- prolog/nan_numerics_prime_lgc.pl

To allow for maximum performance, module `prime_lgc` provides unsafe `public` (not exported) predicates that user code can call directly instead of calling the safe predicates exported by module `prime`.

For info on the implementation, see `library(nan_numerics_prime)`.

NOTE: Predicates in this module are unsafe, i.e. do not validate input arguments and are not steadfast.

author
- Julio P. Di Egidio
version
- 1.2.5-beta
- `library(nan_numerics_prime)`
- GNU GPLv3
To be done
- Integrate `isqrt` function from GMP?
test_(+N:posint) is semidet
True if N is a prime number.
div_(+N:posint, -P:prime) is semidet
True if N is a composite number with P its smallest prime divisor.
div_rev_(+N:posint, -P:prime) is semidet
True if N is a composite number with P its greatest prime divisor.
fact_(+N:posint, -PFs:list(pfact)) is det
PFs is the list of all prime factors of N in ascending order of the prime divisors.

Elements of PFs are of the form `P^F` with P the prime divisor and F the corresponding power.

If N is equal to `1` or if N is a prime number, PFs is `[N^1]`.

gen_(+Inf:posint, -P:prime) is multi
gen_(+Inf:posint, +Sup:posint, -P:prime) is nondet
Generates in ascending order all prime numbers P greater than or equal to Inf, and less than or equal to Sup in the variant with arity `3`. Fails if the prime to the left of Sup is less than the prime to the right of Inf.
gen_p_(+L:prime, -P:prime) is multi
gen_p_(+L:prime, +H:prime, -P:prime) is nondet
Generates in ascending order all prime numbers P starting from L, and up to H in the variant with arity `3`. Fails if H is less than L.
gen_rev_(+Sup:prime, -P:prime) is nondet
gen_rev_(+Inf:posint, +Sup:posint, -P:prime) is nondet
Generates in descending order all prime numbers P less than or equal to Sup, and greater than or equal to Inf in the variant with arity `3`. Fails if Sup is equal to `1` or if the prime to the left of Sup is less than the prime to the right of Inf.
gen_rev_p_(+H:prime, -P:prime) is multi
gen_rev_p_(+L:prime, +H:prime, -P:prime) is nondet
Generates in descending order all prime numbers P starting from H, and down to L in the variant with arity `3`. Fails if H is less than L.
next_(+N:posint, -P:prime) is det
P is the smallest prime number greater than N.
next_p_(+P0:prime, -P:prime) is det
P is the smallest prime number greater than P0.
prev_(+N:posint, -P:prime) is semidet
P is the greatest prime number less than N. Fails if N is less than or equal to `2`.
prev_p_(+P0:prime, -P:prime) is semidet
P is the greatest prime number less than P0. Fails if P is equal to `2`.
right_(+N:posint, -P:prime) is det
P is the smallest prime number greater than or equal to N.
left_(+N:posint, -P:prime) is semidet
P is the greatest prime number less than or equal to N. Fails if N is equal to `1`.