For more information including compatibility, examples and test cases, see https://github.com/petercrlane/r7rslibs
SLIB Documentation: http://people.csail.mit.edu/jaffer/slib/PrimeNumbers.html#PrimeNumbers
0.1. Factor: (import (slib factor))
Functions for testing if numbers are primes, generating prime numbers, and to factor numbers.
These functions use the SolovayStrassen primality test:

Robert Solovay and Volker Strassen, A Fast MonteCarlo Test for Primality, SIAM Journal on Computing, 1977, pp 8485.
0.1.1. factor
factor
takes one argument and returns a list of the prime factors of that
number: the numbers are in no guaranteed order.
> (factor 5) (5) > (factor 100) (5 5 2 2)
0.1.2. jacobisymbol
The jacobisymbol
is used in modular arithmetic with one application, as here,
being tests for primality. The function returns 0, 1 or 1 given two integers.
> (jacobisymbol 15 7) 1 > (jacobisymbol 63 7) 0 > (jacobisymbol 7 15) 1
0.1.3. prime:trials
prime:trials
controls the likelihood that prime?
will accept a composite
number as a prime. The probability is 2^( prime:trials
)
prime:trials
is a parameter object, so you can change it to a higher value, if required:
> (prime:trials) 30 > (prime:trials 100) > (prime:trials) 100
0.1.4. prime?
prime?
returns true or false depending on if the given number passes the
SolovayStrassen primality test.
> (prime? 17) #t > (prime? 1) #f
0.1.5. primes<
primes<
accepts two arguments: a start value and a count. It returns a list
of count
prime numbers less than the start value.
> (primes< 18 2) (13 17)
0.1.6. primes>
primes>
accepts two arguments: a start value and a count. It returns a list
of count
prime numbers greater than the start value.
> (primes> 18 2) (19 23)