mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Release calc version 2.10.2t30
This commit is contained in:
32
lib/bigprime.cal
Normal file
32
lib/bigprime.cal
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
global lib_debug;
|
||||
if (lib_debug >= 0) {
|
||||
print "bigprime(a, m, p) defined";
|
||||
}
|
Reference in New Issue
Block a user