# leto/math--primality

Remove duplicated code introduced by a merge

• Loading branch information...
1 parent 9636c0e commit 3bba000d277febaab2fa1fdc80cb84eef4259d8d committed Feb 5, 2013
Showing with 4 additions and 4 deletions.
1. +4 −4 lib/Math/Primality.pm
 @@ -506,21 +506,21 @@ sub is_prime(\$) { my \$n = shift; \$n = GMP->new("\$n") unless ref(\$n) eq 'Math::GMPz'; + # is it less than 2? return 0 if Rmpz_cmp_ui(\$n, 2) == -1; + # is it a small prime? (<=257) return _is_small_prime(\$n) if Rmpz_cmp_ui(\$n, 257) == -1; + # Divisible by 2? return 0 if Rmpz_even_p(\$n); - # 4127218095 = 3*5*7*11*13*17*19*23*37, 3948078067 = 29*31*41*43*47*53 - return 0 unless 1 == Rmpz_gcd_ui(\$Math::GMPz::NULL, \$n, 4127218095); - return 0 unless 1 == Rmpz_gcd_ui(\$Math::GMPz::NULL, \$n, 3948078067); # The following two gci_ui calls detect if the first few # small primes are factors, which is a very quick test # to filter out numbers with small factors # On 64bit machines, we could use a single GCD with 16294579238595022365 - # but to work on 32bit machines, we split that into 4127218095*3948078067 + # but to work on 32bit machines, we split that into 4127218095 * 3948078067 # 4127218095 = 3*5*7*11*13*17*19*23*37 return 0 unless 1 == Rmpz_gcd_ui(\$Math::GMPz::NULL, \$n, 4127218095);

#### 0 comments on commit `3bba000`

Please sign in to comment.