iota-0.1.0.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Math.Modulus.Log

Synopsis

Documentation

logMod :: Int -> Int -> Int -> Maybe Int Source #

Baby-step Giant-step

a^x = b (mod p) p is prime

O(sqrt P * log P)

>>> logMod 3 27 998244353
Just 3
>>> logMod 3 123456789 998244353
Just 772453214
>>> logMod 1 2 1000000007
Nothing