Permalink
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
2 parents 10fd0ec + 0045721 commit 3d13dc9cb4accc7faa57ea0ca0514b45d1e50f1c @leto committed Sep 26, 2012
Showing with 3 additions and 12 deletions.
  1. +3 −12 lib/Math/Primality.pm
View
@@ -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 );

0 comments on commit 3d13dc9

Please sign in to comment.