How to find (a*b)%m for large a and b?

224 Views Asked by At

I have searched on google. On one site it is said that (ab)%m = a%mb%m and on another site i found (ab)%m = (a%mb%m)%m. So which is the correct way?

1

There are 1 best solutions below

1
On BEST ANSWER

The first is incorrect. for example, if m is 10, and a and b are 9, then (a%m)=9, (b%m)=9, and (a%m)(b%m) is 18 - greater than m!