This file is part of the GNU MP Library test suite.
The GNU MP Library test suite 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.
The GNU MP Library test suite 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
the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */
#include"testutils.h"
staticint
isprime (unsignedlongint t)
{ unsignedlongint q, r, d;
if (t < 32) return (0xa08a28acUL >> t) & 1; if ((t & 1) == 0) return 0;
if (t % 3 == 0) return 0; if (t % 5 == 0) return 0; if (t % 7 == 0) return 0;
for (d = 11;;)
{
q = t / d;
r = t - q * d; if (q < d) return 1; if (r == 0) break;
d += 2;
q = t / d;
r = t - q * d; if (q < d) return 1; if (r == 0) break;
d += 4;
} return 0;
}
staticvoid
check_one (mpz_srcptr n, int want)
{ int got;
got = mpz_probab_prime_p (n, 25);
/* "definitely prime" is fine if we only wanted "probably prime" */ if (got == 2 && want == 1)
want = 2;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.