I have three integers A, B (less than 10^12) and C (less than 10^15). I want to calculate (A * B) % C. I know that
(A * B) % C = ((A % C) * (B % C)) % C
but say if A = B = 10^11 then above expression will cause an integer overflow. Is there any simple solution for above case or I have to use fast multiplication algorithms.
If I have to use fast multiplication algorithm then which algorithm I should use.
EDIT: I have tried above problem in C++ (which does not cause overflow, not sure why), but isn't the answer should be zero?
Thanks in advance.
712049423024128
when you were expecting0
. – Alixaliza