Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix is_strong_lucas_pseudoprime. passing Perl undefs to GMP is bad juju

  • Loading branch information...
commit 423ad115294216b4675b545515c784be24f58ad4 1 parent 8e2e204
@leto authored
Showing with 4 additions and 2 deletions.
  1. +3 −1 lib/Math/Primality.pm
  2. +1 −1  t/is_strong_lucas_pseudoprime.t
View
4 lib/Math/Primality.pm
@@ -184,7 +184,9 @@ sub _find_dpq_selfridge($) {
my $wd;
while (1) {
$wd = $d * $sign;
- my $gcd = Rmpz_gcd_ui(undef, $n, $wd);
+ my $gcd = Math::GMPz->new;
+
+ Rmpz_gcd_ui($gcd, $n, $wd);
if ($gcd > 1 && Rmpz_cmp_ui($n, $gcd) > 0) {
debug "1 < $gcd < $n => $n is composite with factor $wd";
return 0;
View
2  t/is_strong_lucas_pseudoprime.t
@@ -14,6 +14,6 @@ TODO: {
ok(is_strong_lucas_pseudoprime($z), "is_strong_lucas_pseudoprime should handle Math::GMPz objects");
ok(is_strong_lucas_pseudoprime(2), "is_strong_lucas_pseudoprime should return true for 2");
ok(is_strong_lucas_pseudoprime(705), "is_strong_lucas_pseudoprime should return true for the first lucas pseudoprime");
-}
+};
ok(!is_strong_lucas_pseudoprime(9), 'is_strong_lucas_pseudoprime deals with perfect squares');
Please sign in to comment.
Something went wrong with that request. Please try again.