Math.Modulus.Sqrt
legendreSymbol :: Int -> Int -> Int Source #
Legendre symbol (Euler's criterion)
p is odd prime
sqrtMod :: Int -> Int -> [Int] Source #
x^2 = a (mod p) p is prime
x^2 = a (mod p)
>>> sqrtMod 2 1000000007 [59713600,940286407] >>> sqrtMod 3 1000000007 [82062379,917937628] >>> sqrtMod 4 1000000007 [2,1000000005] >>> sqrtMod 5 1000000007 []
>>>
sqrtMod 2 1000000007
sqrtMod 3 1000000007
sqrtMod 4 1000000007
sqrtMod 5 1000000007
cipolla :: Int -> Int -> Int Source #
cipolla a p ^ 2 = a (mod p) p is odd prime, (a | p) = 1
cipolla a p ^ 2 = a (mod p)
>>> cipolla 9 998244353 3 >>> cipolla 9 1000000007 1000000004
cipolla 9 998244353
cipolla 9 1000000007