Guile Library

(math primes)

Overview

This module defines functions related to prime numbers, and prime factorization.

Usage

prime:trials
[Variable]

This is the maximum number of iterations of Solovay-Strassen that will be done to test a number for primality. The chance of error (a composite being labelled prime) is (expt 2 (- prime:trials)).

prime? n
[Function]

Returns #f if n is composite, and t if it is prime. There is a slight chance, (expt 2 (- prime:trials)), that a composite will return #t.

prime> start
[Function]

Return the first prime number greater than start. It doesn't matter if start is prime or composite.

primes> start count
[Function]

Returns a list of the first count prime numbers greater than start.

prime< start
[Function]

Return the first prime number less than start. It doesn't matter if start is prime or composite. If no primes are less than start, #f will be returned.

primes< start count
[Function]

Returns a list of the first count prime numbers less than start. If there are fewer than count prime numbers less than start, then the returned list will have fewer than start elements.

factor k
[Function]

Returns a list of the prime factors of k. The order of the factors is unspecified. In order to obtain a sorted list do (sort! (factor k) <).