Exemple #1
0
        public LCG GetInverse()
        {
            // f(x) = A*x + b (mod m)
            // f^(-1)(x) =
            var isInvertible = ModHelper.TryGetModInverse(A, M, out BigInteger aInverse);

            if (!isInvertible)
            {
                throw new Exception($"{A} is not invertible mod {M}");
            }
            var result = new LCG(aInverse, -1 * B * aInverse, M);

            return(result);
        }