Skip to content

Commit

Permalink
Return 0 for rad(0) and core(0).
Browse files Browse the repository at this point in the history
  • Loading branch information
trizen committed Aug 2, 2020
1 parent f31109e commit 50cfdfd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/Sidef/Types/Number/Number.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11742,20 +11742,19 @@ package Sidef::Types::Number::Number {
sub rad { # A007947
my %f;
@f{Math::Prime::Util::GMP::factor(&_big2uistr // goto &nan)} = ();
exists($f{'0'}) and return ONE;
exists($f{'0'}) and return ZERO;
my $r = Math::Prime::Util::GMP::vecprod(CORE::keys %f);
($r < ULONG_MAX) ? __PACKAGE__->_set_uint($r) : __PACKAGE__->_set_str('int', $r);
}

sub core { # A007913
my ($n) = @_;

# Multiplicative with:
# a(p^k) = p^(k mod 2)

my %f;
++$f{$_} for Math::Prime::Util::GMP::factor(_big2uistr($n) // goto &nan);
exists($f{'0'}) and return ONE;
++$f{$_} for Math::Prime::Util::GMP::factor(&_big2uistr // goto &nan);
exists($f{'0'}) and return ZERO;
my $r = Math::Prime::Util::GMP::vecprod(grep { $f{$_} % 2 } CORE::keys %f);
($r < ULONG_MAX) ? __PACKAGE__->_set_uint($r) : __PACKAGE__->_set_str('int', $r);
}
Expand Down

0 comments on commit 50cfdfd

Please sign in to comment.