Copyright 2000-2002, 2012, 2013, 2017-2018 Free Software Foundation, Inc.
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 <stdio.h> #include <stdlib.h>
#include"testutils.h"
/* Usage: t-fac_ui [x|num]
With no arguments testing goes up to the initial value of "limit" below. With a number argument tests are carried that far, or with a literal "x" tests are continued without limit (this being meant only for development
purposes). */
void checkWilson (mpz_t f, unsignedlong n)
{ unsignedlong m, a;
mpz_2fac_ui (f, 2 * n - 1);
a = mpz_fdiv_q_ui (f, f, n);
m = mpz_fdiv_ui (f, n); if ((m != n - 1) || (a != 0))
{
printf ("mpz_2fac_ui(%lu) wrong\n", 2 * n - 1);
printf (" Wilson's theorem not verified: got (%lu, %lu), expected (0, %lu).\n", a, m, n - 1);
abort ();
}
mpz_fac_ui (f, n - 1);
m = mpz_fdiv_ui (f, n); if ( m != n - 1)
{
printf ("mpz_fac_ui(%lu) wrong\n", n - 1);
printf (" Wilson's theorem not verified: got %lu, expected %lu.\n",m ,n - 1);
abort ();
}
}
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.