[libmath-prime-util-perl] 162/181: Honor rounds in Fermat

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:51:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.36
in repository libmath-prime-util-perl.

commit 3f1b612534daa48e261c756f3e5f3603e24df4bb
Author: Dana Jacobsen <dana at acm.org>
Date:   Fri Jan 10 20:54:37 2014 -0800

    Honor rounds in Fermat
---
 factor.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/factor.c b/factor.c
index 636aebc..22064da 100644
--- a/factor.c
+++ b/factor.c
@@ -385,15 +385,14 @@ UV divisor_sum(UV n, UV k)
 int fermat_factor(UV n, UV *factors, UV rounds)
 {
   IV sqn, x, y, r;
-
   MPUassert( (n >= 3) && ((n%2) != 0) , "bad n in fermat_factor");
-
   sqn = isqrt(n);
   x = 2 * sqn + 1;
   y = 1;
   r = (sqn*sqn) - n;
 
   while (r != 0) {
+    if (rounds-- == 0) { factors[0] = n; return 1; }
     r += x;
     x += 2;
     do {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list