4.4BSD/usr/src/contrib/calc-1.26.4/lib/nextprim.cal

/*
 * Copyright (c) 1993 David I. Bell
 * Permission is granted to use, distribute, or modify this source,
 * provided that this copyright notice remains intact.
 *
 * Function to find the next prime (probably).
 */

define nextprime(n, tries)
{
	if (isnull(tries))
		tries = 20;
	if (iseven(n))
		n++;
	while (ptest(n, tries) == 0)
		n += 2;
	return n;
}

global lib_debug;
if (!isnum(lib_debug) || lib_debug>0) print "nextprime(n, tries) defined";