[libmath-prime-util-perl] 19/54: Better is_power
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:52:08 UTC 2015
This is an automated email from the git hooks/post-receive script.
ppm-guest pushed a commit to annotated tag v0.38
in repository libmath-prime-util-perl.
commit d29c977ee8d90a7a373cc7fb5124d423e832eddd
Author: Dana Jacobsen <dana at acm.org>
Date: Mon Feb 3 18:36:08 2014 -0800
Better is_power
---
lib/Math/Prime/Util/PP.pm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index 358abee..a6ec6f2 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -1431,9 +1431,9 @@ sub is_power {
my ($n, $a) = @_;
return 0 if $n <= 3 || $n != int($n);
if (defined $a && $a != 0) {
- my $power = is_power($n);
- return 0 unless $power != 0;
- return !($power % $a);
+ return _is_perfect_square($n) if $a == 2;
+ $n = Math::BigInt->new("$n") unless ref($n) eq 'Math::BigInt';
+ return $n->copy->broot($a)->bint->bpow($a) == $n;
}
#return 2 if _is_perfect_square($n);
$n = Math::BigInt->new("$n") unless ref($n) eq 'Math::BigInt';
--
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