next up previous
Next: Up: Previous:

Finding the gcd

Given prime factorizations of positive integers a and b,

\begin{displaymath}a \;=\; p_1^{e_1} p_2^{e_2} \cdots p_r^{e_r}, \;\;\;\;\;
b \;=\; p_1^{f_1} p_2^{f_2} \cdots p_r^{f_r},\end{displaymath}

where some ei, fi may be 0.

Then gcd(a,b) = \(p_1^{min(e_1,f_1)} p_2^{min(e_2,f_2)} \cdots p_r^{min(e_r,f_r)}\).

Example: gcd(255, 675) = \(3^1 \;*\; 5^1 \;*\; 17^0\) = 3 * 5 = 15

However, factoring is not a polynomial time algorithm.


next up previous
Next: Up: Previous: