Calculating $n$ mod $m$ given the prime factorization of $n$

1.1k Views Asked by At

Say I have the prime factorization of a large integer $n$. $$n=p_1^{a_{1}}\cdot p_2^{a_{2}}\ldots p_k^{a_{k}}$$ However, I do not have $n$ itself.

How do I calculate $n$ mod $m$, given only $n$'s prime factorization and the mod $m$, without factoring $n$ (if it's efficiently possible at all)?

1

There are 1 best solutions below

2
On

Find ${p^w} \pmod m$ for all $p$ from the prime factorization of n.
Then multiply these values and take modulo m
(btw, you'd better take modulo m as you multiply).