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
|
#!/bin/sh
# test file for P-1 method
#
# Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012, 2016
# Paul Zimmermann, Alexander Kruppa, Dave Newman, Jim Fougeron, David Cleaver
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program 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 General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, see
# http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
PM1="${1:-./ecm} -pm1"
# Call with "checkcode $? n" to check that return code is n
# the return code is (see ecm-ecm.h):
# 0: no factor found
# 1: error (for example out of memory)
# 2: composite factor found with composite cofactor
# 6: prime factor found with composite cofactor
# 8: input number found
# 10: composite factor found with prime cofactor
# 14: prime factor found with prime cofactor
checkcode () {
if [ $1 != $2 ]
then
echo "############### ERROR ###############"
echo "Expected return code $2 but got $1"
exit 1
fi
}
# exercise gathering primes between cascade_limit < p < B0
echo 123 | $PM1 4.42e8; checkcode $? 8
# exercise factor of F_15
echo "2^(2^15)+1" | $PM1 -go 2097152 3 193; checkcode $? 6
echo "All P-1 tests are ok."
echo ""
|