1/* 2 * bigprime - a prime test, base a, on p*2^x+1 for even x>m 3 * 4 * Copyright (C) 1999 David I. Bell 5 * 6 * Calc is open software; you can redistribute it and/or modify it under 7 * the terms of the version 2.1 of the GNU Lesser General Public License 8 * as published by the Free Software Foundation. 9 * 10 * Calc is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 13 * Public License for more details. 14 * 15 * A copy of version 2.1 of the GNU Lesser General Public License is 16 * distributed with calc under the filename COPYING-LGPL. You should have 17 * received a copy with calc; if not, write to Free Software Foundation, Inc. 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 * 20 * Under source code control: 1991/05/22 21:56:32 21 * File existed as early as: 1991 22 * 23 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ 24 */ 25 26 27define bigprime(a, m, p) 28{ 29 local n1, n; 30 31 n1 = 2^m * p; 32 for (;;) { 33 m++; 34 n1 += n1; 35 n = n1 + 1; 36 if (isodd(m)) 37 continue; 38 print m; 39 if (pmod(a, n1 / 2, n) != n1) 40 continue; 41 if (pmod(a, n1 / p, n) == 1) 42 continue; 43 print " " : n; 44 } 45} 46