Initial revision
[LeanCalc.git] / help / isprime
1 NAME
2     isprime - whether a small integer is prime
3
4 SYNOPSIS
5     isprime(x [,err])
6
7 TYPES
8     x           int
9     err         int
10
11     return      int
12
13 DESCRIPTION
14     Determine if x is is a small prime.  This function will return
15     1 if x is a small prime.  If x is even, this function will
16     return 0.  If x is negative or a small composite (non-prime),
17     0 will be returned.
18
19     If x is a large positive odd value and the err argument is
20     given, this function return err.  If x is a large positive odd
21     value and the err argument is not given, an error will be
22     generated.
23
24     Note that normally this function returns the integer 0 or 1.
25     If err is given and x is a large positive odd value, then err
26     will be returned.
27
28 EXAMPLE
29     > print isprime(-3), isprime(1), isprime(2)
30     0 0 1
31
32     > print isprime(21701), isprime(1234577), isprime(1234579)
33     1 1 0
34
35     > print isprime(2^31-9), isprime(2^31-1), isprime(2^31+11)
36     0 1 1
37
38     > print isprime(2^32+1, -1), isprime(3^99, 2), isprime(4^99, 2)
39     -1 2 0
40
41 LIMITS
42     err not given  and  (y is even  or  y < 2^32)
43
44 LINK LIBRARY
45     FLAG zisprime(ZVALUE x)     (return 1 if prime, 0 not prime, -1 if >= 2^32)
46
47 SEE ALSO
48     factor, lfactor, nextprime, prevprime, pfact, pix,
49     isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
50     ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
51     isobjtype, isodd, isrand, israndom, isreal, isrel,
52     issimple, issq, isstr, istype
53