Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "nan_numerics_prime"

Title:Nan.Numerics.Prime - A simple prime number library
Rating:Not rated. Create the first rating!
Latest version:1.2.5
SHA1 sum:09eccfe075aef4aaf8df8b5f9e87a82d7018124b
Author:Julio P. Di Egidio <julio@diegidio.name>
Home page:http://julio.diegidio.name/Projects/Nan.Numerics.Prime/
Download URL:https://github.com/jp-diegidio/Nan.Numerics.Prime-Prolog/releases/download/1.2.5-beta/nan_numerics_prime-1.2.5.zip
Provides:numerics
prime

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
1.0f07cd9a346ebc4683c331e321e38573339df24852http://julio.diegidio.name/Projects/Nan.Numerics.Prime/Prolog/nan_numerics_prime-1.0.zip
1.1332fb247a59c55e11cebcadcfe52679af11a52941http://julio.diegidio.name/Projects/Nan.Numerics.Prime/Prolog/nan_numerics_prime-1.1.zip
1.2.3fa987c53c9f025579b50bd2768dc1103eb815beb1https://github.com/jp-diegidio/Nan.Numerics.Prime-Prolog/releases/download/1.2.3-beta/nan_numerics_prime-1.2.3.zip
1.2.4d89adfd6a48dfefd4799654b600995d728b618811https://github.com/jp-diegidio/Nan.Numerics.Prime-Prolog/releases/download/1.2.2-beta/nan_numerics_prime-1.2.4.zip
1.2.509eccfe075aef4aaf8df8b5f9e87a82d7018124b70https://github.com/jp-diegidio/Nan.Numerics.Prime-Prolog/releases/download/1.2.5-beta/nan_numerics_prime-1.2.5.zip

Nan.Numerics.Prime/Prolog 1.2.5-beta Nan.Numerics.Prime A simple prime number library Copyright 2016 Julio P. Di Egidio Licensed under GNU GPLv3. http://julio.diegidio.name/Projects/Nan.Numerics.Prime/ https://github.com/jp-diegidio/Nan.Numerics.Prime-Prolog/

library(nan_numerics_prime)

Module prime provides predicates to test (positive integer) numbers for primality, find divisors and factor numbers, generate prime numbers in some interval, find consecutive prime numbers, and save/load all prime numbers up to some value to/from a file or stream.

All predicates in module prime are safe, i.e. validate input arguments and ensure steadfastness. For maximum performance, user code can directly call the unsafe public (not exported) predicates in module prime_lgc.

Implements a variant of the Miller-Rabin primality test that is deterministic for numbers up to 3317044064679887385961980, otherwise it is probabilistic with the number of iterations fixed at 20.

For better performance, leverages a prime wheel of level 4, i.e. generated by the first 4 consecutive prime numbers, and the memoization of pairs of consecutive prime numbers.

NOTE: Since the primality test in use is probabilistic in general, this library is not suitable for cryptographic applications.

This library was developed and tested with: SWI-Prolog 7.3.25 - http://www.swi-prolog.org/

Usage example:

?- pack_install(nan_numerics_prime).
true.

?- use_module(library(nan_numerics_prime)).
true.

?- time(prime_right(1234567891012345678901234567890123456789011111, P)).
% 1,205 inferences, 0.000 CPU in 0.000 seconds (?% CPU, Infinite Lips)
P = 1234567891012345678901234567890123456789011139.

?- time(prime_lgc:right_(1234567891012345678901234567890123456789011111, P)).
% 1,197 inferences, 0.000 CPU in 0.000 seconds (?% CPU, Infinite Lips)
P = 1234567891012345678901234567890123456789011139.

To be done: Implement prime counting/n-th prime functions. To be done: Implement probabilitic test error estimates? To be done: Implement deterministic tests (elliptic curves)?

Contents of pack "nan_numerics_prime"

Pack contains 20 files holding a total of 209K bytes.