File: bigprime.cal

package info (click to toggle)
apcalc 2.10.3t5.46-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 4,276 kB
  • ctags: 3,115
  • sloc: ansic: 47,720; makefile: 3,702; awk: 105; sed: 55
file content (31 lines) | stat: -rw-r--r-- 547 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright (c) 1995 David I. Bell
 * Permission is granted to use, distribute, or modify this source,
 * provided that this copyright notice remains intact.
 *
 * A prime test, base a, on p*2^x+1 for even x>m.
 */

define bigprime(a, m, p)
{
	local n1, n;

	n1 = 2^m * p;
	for (;;) {
		m++;
		n1 += n1;
		n = n1 + 1;
		if (isodd(m))
			continue;
		print m;
		if (pmod(a, n1 / 2, n) != n1)
			continue;
		if (pmod(a, n1 / p, n) == 1)
			continue;
		print "	" : n;
	}
}

if (config("lib_debug") >= 0) {
    print "bigprime(a, m, p) defined";
}