| Bill Allombert on Tue, 21 Nov 2023 14:22:02 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: sqrt(x,n) for non-prime n? |
On Tue, Nov 21, 2023 at 09:35:53AM +0100, hermann@stamm-wilbrandt.de wrote: > Modular sqrt does not work with non-prime modulus: > > ? sqrt(Mod(-1,125)) > *** at top-level: sqrt(Mod(-1,125)) > *** ^----------------- > *** sqrt: not a prime number in sqrt [modulus]: 125. > *** Break loop: type 'break' to go back to GP prompt > break> Indeed, but you can do ? issquare(Mod(-1,125),&z) %3 = 1 ? z %4 = Mod(57,125) The problem is that when given Mod(a,b) we do not want to have to test b for primality each time... Cheers, Bill.