If you have the product of two numbers and want to calculate the modulus of said product

(A*B)mod C    Where A,B and C are integers

let A=mC+a  B=nC+b  where a & b are the modulus of A & B respectively and m & n are integers

Substituting:

(mC+a)(nC+b)mod C 

[ mnC^2+(an+bm)C+ab ]mod C   and because everything is an integer

[ mnC^2+(an+bm)C ]mod C=0   and thus

(A*B)mod C = (ab)mod C = ab   since a & b are already the modulus of A & B. Now if this product is larger than C the modulus function will need be reapplied as in the following example:

Example:  A=8 B=8 C=5

8^2 mod 5 =64 mod 5 = 4 

(8 mod 5)* (8 mod 5)= 9 

9 mod 5 = 4    which is the same as above

Categories: Math

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *