I was trying this:
BigInteger.ModPow(x, -1, z);
But this method can't use -1 as Pow argument. Is there any already implemented class in C# that can do that, or I need to make my own class ?
Keep your highschool math book identity in mind: x ^ -1 == 1/x. So this is simply:
BigInteger.DivRem(BigInteger.Divide(BigInteger.One, x), z, out remainder);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.