2 isprime - whether a small integer is prime
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),
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
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
29 ; print isprime(-3), isprime(1), isprime(2)
32 ; print isprime(21701), isprime(1234577), isprime(1234579)
35 ; print isprime(2^31-9), isprime(2^31-1), isprime(2^31+11)
38 ; print isprime(2^32+1, -1), isprime(3^99, 2), isprime(4^99, 2)
42 err not given and (y is even or y < 2^32)
45 FLAG zisprime(ZVALUE x) (return 1 if prime, 0 not prime, -1 if >= 2^32)
48 factor, lfactor, nextcand, nextprime, prevcand, prevprime,
51 ## Copyright (C) 1999-2006 Landon Curt Noll
53 ## Calc is open software; you can redistribute it and/or modify it under
54 ## the terms of the version 2.1 of the GNU Lesser General Public License
55 ## as published by the Free Software Foundation.
57 ## Calc is distributed in the hope that it will be useful, but WITHOUT
58 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
59 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
60 ## Public License for more details.
62 ## A copy of version 2.1 of the GNU Lesser General Public License is
63 ## distributed with calc under the filename COPYING-LGPL. You should have
64 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
65 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
67 ## @(#) $Revision: 30.1 $
68 ## @(#) $Id: isprime,v 30.1 2007/03/16 11:10:42 chongo Exp $
69 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/isprime,v $
71 ## Under source code control: 1994/10/21 02:21:29
72 ## File existed as early as: 1994
74 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
75 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/