/usr/share/calc/help/nextcand is in apcalc-common 2.12.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | NAME
nextcand - next candidate for primeness
SYNOPSIS
nextcand(n [,count [, skip [, residue [,modulus]]]])
TYPES
n integer
count integer with absolute value less than 2^24, defaults to 1
skip integer. defaults to 1
residue integer, defaults to 0
modulus integer, defaults to 1
return integer
DESCRIPTION
If modulus is nonzero, nextcand(n, count, skip, residue, modulus)
returns the least integer i greater than abs(n) expressible as
residue + k * modulus, where k is an integer, for which
ptest(i,count,skip) == 1, or if there is no such integer, zero.
If abs(n) < 2^32, count >= 0, and the returned value i is not zero, then
i is definitely prime. If count is not zero and the returned
value i is greater than 2^32, then i is probably prime, particularly
if abs(count) > 1.
If skip == 0, and abs(n) >= 2^32 or count < 0, the probabilistic test with
random bases is used so that if n is composite the
probability that it passes ptest() is less than 4^-abs(count).
If skip == 1 (the default value), the bases used in the probabilistic
test are the first abs(count) primes 2, 3, 5, ...
For other values of skip, the bases used in the probabilistic tests
are the abs(count) consecutive integers, skip, skip + 1, skip + 2, ...
In any case, if the integer returned by nextcand() is not zero,
all integers between abs(n) and that integer are composite.
If modulus is zero, the value returned is that of residue if this is
greater than abs(n) and ptest(residue,count,skip) = 1. Otherwise
zero is returned.
RUNTIME
The runtime for v = nextcand(n, ...) will depend strongly on the
number and nature of the integers between n and v. If this number
is reasonably large the size of count is largely irrelevant as the
compositeness of the numbers between n and v will usually be
determined by the test for small prime factors or one pseudoprime
test with some base b. If N > 1, count should be positive so that
candidates divisible by small primes will be passed over quickly.
On the average for random n with large word-count N, the runtime seems
to be roughly K/N^3 some constant K.
EXAMPLE
; print nextcand(50), nextcand(112140,-2), nextcand(112140,-3)
53 112141 112153
; print nextcand(100,1,1,1,6), nextcand(100,1,1,-1,6)
103 101
; print nextcand(100,1,1,2,6), nextcand(100,1,1,303,202)
1 101
; print nextcand(2e60, 1, 1, 31, 1e30)
2000000000000000000000000000053000000000000000000000000000031
LIMITS
none
LINK LIBRARY
int znextcand(ZVALUE n, long count, long skip, ZVALUE res, ZVALUE mod,
ZVALUE *cand)
SEE ALSO
factor, isprime, lfactor, nextprime, prevcand, prevprime,
pfact, pix, ptest
## Copyright (C) 1999-2006 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: nextcand,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/nextcand,v $
##
## Under source code control: 1996/02/25 00:27:43
## File existed as early as: 1996
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|