aboutsummaryrefslogtreecommitdiffstats
path: root/factor.txi
blob: 90569ea6531a98fd214b9aa9312de413c550187d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

@defvar prime:prngs

@var{prime:prngs} is the random-state (@pxref{Random Numbers}) used by these
procedures.  If you call these procedures from more than one thread
(or from interrupt), @code{random} may complain about reentrant
calls.
@end defvar
@emph{Note:} The prime test and generation procedures implement (or
use) the Solovay-Strassen primality test. See

@itemize @bullet
@item Robert Solovay and Volker Strassen,
@cite{A Fast Monte-Carlo Test for Primality},
SIAM Journal on Computing, 1977, pp 84-85.
@end itemize


@defun jacobi-symbol p q

Returns the value (+1, @minus{}1, or 0) of the Jacobi-Symbol of
exact non-negative integer @var{p} and exact positive odd integer @var{q}.
@end defun


@defvar prime:trials

@var{prime:trials} the maxinum number of iterations of Solovay-Strassen that will
be done to test a number for primality.
@end defvar

@defun prime? n

Returns @code{#f} if @var{n} is composite; @code{#t} if @var{n} is prime.
There is a slight chance @code{(expt 2 (- prime:trials))} that a
composite will return @code{#t}.
@end defun


@defun primes< start count

Returns a list of the first @var{count} prime numbers less than
@var{start}.  If there are fewer than @var{count} prime numbers
less than @var{start}, then the returned list will have fewer than
@var{start} elements.
@end defun


@defun primes> start count

Returns a list of the first @var{count} prime numbers greater than @var{start}.
@end defun


@defun factor k

Returns a list of the prime factors of @var{k}.  The order of the
factors is unspecified.  In order to obtain a sorted list do
@code{(sort! (factor @var{k}) <)}.
@end defun