[Gmp-commit] /var/hg/gmp: tests/mpz/t-fac_ui.c: Check Wilson's theorem on a b...

mercurial at gmplib.org mercurial at gmplib.org
Fri Apr 13 23:21:21 CEST 2012


details:   /var/hg/gmp/rev/e68f8fefe22d
changeset: 14817:e68f8fefe22d
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Fri Apr 13 23:21:11 2012 +0200
description:
tests/mpz/t-fac_ui.c: Check Wilson's theorem on a big value

diffstat:

 ChangeLog            |   2 ++
 tests/mpz/t-fac_ui.c |  12 ++++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diffs (34 lines):

diff -r 92d03208c873 -r e68f8fefe22d ChangeLog
--- a/ChangeLog	Fri Apr 13 11:11:23 2012 +0200
+++ b/ChangeLog	Fri Apr 13 23:21:11 2012 +0200
@@ -7,6 +7,8 @@
 	* mini-gmp/mini-gmp.c (mpz_fac_ui, mpz_bin_uiui): Trivial
 	implementation.
 
+	* tests/mpz/t-fac_ui.c: Check Wilson's theorem on a big value.
+
 2012-04-12  Torbjorn Granlund  <tege at gmplib.org>
 
 	* mpn/x86_64/fastsse/lshift-movdqu2.asm: New file.
diff -r 92d03208c873 -r e68f8fefe22d tests/mpz/t-fac_ui.c
--- a/tests/mpz/t-fac_ui.c	Fri Apr 13 11:11:23 2012 +0200
+++ b/tests/mpz/t-fac_ui.c	Fri Apr 13 23:21:11 2012 +0200
@@ -83,6 +83,18 @@
       mpz_mul_ui (f, f, n+1);  /* (n+1)! = n! * (n+1) */
     }
 
+  n = 1048573; /* a prime */
+  if (n > MP_LIMB_T_MAX)
+    n = 65521; /* a smaller prime :-) */
+  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 ();
+    }
+
   mpz_clear (df[0]);
   mpz_clear (df[1]);
   mpz_clear (f);


More information about the gmp-commit mailing list