Math-Prime-Util
Math-Prime-Util copied to clipboard
PP sqrtmod(-a, n) fails
% $PERL -MMath::Prime::Util -wle 'print $Math::Prime::Util::VERSION'
0.73
% $PERL -MMath::Prime::Util=sqrtmod -wle 'print sqrtmod(-1, 17) // "undef"'
4
% MPU_NO_XS=1 $PERL -MMath::Prime::Util=sqrtmod -wle 'print sqrtmod(-1, 17) // "undef"'
undef
%
Found by observation of the code. I didn't check if negative modulus was supposed to be supported, that may also be a problem.
Also seems to be fixed in the sqrtmod / rootmod rewrite. Negative inputs are supported, and the documentation indicates we'll use the absolute value (just like Pari/GP). I tried to be more consistent with the *mod functions.