I came across a problem whose answer is in the form of ((a1 x a2 x a3…x an)/(b1 x b2 x b3 x…bn))mod n.
All a and b are very large so actual multiplication and division are not possible.
I know (a x b)%m can be written as ((a%m)x(b%m))%m, but if I simplify using that and do A/B, I’m getting the wrong answer.
Please help me with this.
Update: Forgot to mention that the result of (a1 x a2 x a3…x an)/(b1 x b2 x b3 x…bn) is always a whole number, i.e values of all B’s get cancelled by some A’s.