Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
commit 3d13dc9cb4accc7faa57ea0ca0514b45d1e50f1c 2 parents 10fd0ec + 0045721
@leto authored
Showing with 3 additions and 12 deletions.
  1. +3 −12 lib/Math/Primality.pm
View
15 lib/Math/Primality.pm
@@ -231,18 +231,9 @@ sub is_strong_pseudoprime($;$)
}
map {
- # successively square $residue, $n is a strong psuedoprime
- # if any of these are congruent to -1 (mod $n)
- Rmpz_mul($residue,$residue,$residue); # $residue = $residue * $residue
- debug "$_: r=$residue" if DEBUG;
-
- my $mod = GMP->new();
- Rmpz_mod($mod, $residue, $n); # $mod = $residue mod $n
- debug "$_:$residue % $n = $mod " if DEBUG;
- $mod = Rmpz_cmp($mod, $m);
-
- if ($mod == 0) {
- debug "$_:$mod == $m => spsp!" if DEBUG;
+ Rmpz_powm($residue, $residue, GMP->new(2), $n);
+ if (Rmpz_cmp($residue, $m) == 0) {
+ debug "$_:$residue == $m => spsp!" if DEBUG;
return 1;
}
} ( 1 .. $s-1 );
Please sign in to comment.
Something went wrong with that request. Please try again.