modulus operation division property

╄→гoц情女王★ 提交于 2019-12-24 09:13:10

问题


i have an equation ,

((a*b*c*d)/(e*f*g*h))%m

My question is , Can i first apply multiplication property

(a*b) mod(n) = (a*mod(n)) * (b*mod(n) ) mod(n)

to numerator and then denominator , so that numerator and denominator becomes a single value , and then solve the division operation?

(a/b) mod(n) = (a*inv(b)) mod(n)    

回答1:


Let N = a*b*c*d and D = e*f*g*h. We want to calculate:

(N/D) mod n = (N * inv(D)) mod n

We can use the multiplication property here in the following way:

(N * inv(D)) mod n = ((N mod n) * (inv(D) mod n)) mod n

To calculate N mod n we can apply the multiplication property again so the first part of answer is yes - you can apply the multiplication property to the numerator before solving the division because you will have to do it anyway.

The result of (inv(D) mod n) is a number X that satisfies the equation:

(D * X) mod n = 1
((D mod n) * (X mod n)) mod n = 1

If you apply the multiplication property to the denominator before solving the division you will get:

(((D mod n) mod n) * (X mod n)) mod n = 1

However (D mod n) mod n = D mod n so it doesn't matter. It means that the second part of the answer is also yes - you can apply the multiplication property to the denominator before solving the division.



来源:https://stackoverflow.com/questions/26826787/modulus-operation-division-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!