I didn’t find anything that clears my doubt on Google.

Given three positive integers a,b and m, the task is to find (a/b) under modulo m.(modular division)

modular division is possible if and only if gcd(b,m) is 1.

Why do we calculate (a/b)%m as (mod_inverse(b,m) * a)%m ??

Can’t we simply calculate a/b and then modulo it with m?

Can anyone please explain me the significance of modular division?

For eg., we do (a+b)%m as (a%m + b%m)%m to avoid overflow issues(same with (a*b)%m and (a-b)%m ).

But in case of division, there is no overflow, as the result of (a/b) is always going to be less than or equal to **a**(given that a and b are integers).

Any help is appreciated.