Блог пользователя AFN

Автор AFN, история, 7 лет назад, По-английски

Hi everyone!

I'm really facing problems in when to use modular inverse. I know that you should use it when calculating the following

(a / b)%p = (a * bp - 2)%p [Only when p is prime]

I know there is a case when subtracting, but I don't know how you do it exactly, can you tell me how? And are there any other cases?

Thanks in advance.

  • Проголосовать: нравится
  • -16
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Remember, the modular inverse of some number a modulo m, is a number b such that:

a·b ≡ 1 (mod m)

That's why you use it when you have to do divisions modulo some number .

However, a number a has inverse modulo m iff they are coprime (gcd(a, m) = 1)

If m is prime, you can apply the formula you mentioned in your post. Otherwise, you have to find the modular inverse using another method (for example, Extended GCD)

I don't know what do you mean with "case when subtracting". If you have to perform a subtraction between two numbers modulo m, there's no need to use the modular inverse.