 
 
 
 
 
   
 ?  Yep.
Watch closely:
?  Yep.
Watch closely:
 
 
 divides both
 divides both  and
 and  , then it
automatically divides
, then it
automatically divides  , and of course
, and of course  divides
 divides  .  Also, if a number
divides both
.  Also, if a number
divides both  and
 and  , then it has got to divide
, then it has got to divide  as well!
So we have made progress:
 as well!
So we have made progress:
 
 
 .
Just keep at it:
.
Just keep at it:
|  |  | |
|  |  | |
|  |  | 
 , which is
, which is  because
 
because  , so
, so
 
The Algorithm: 
That was an illustration of Euclid's algorithm.
You just ``Divide and switch.''
More formally, fix 
 with
 with  .
Using ``divide with quotient and remainder'',
write
.
Using ``divide with quotient and remainder'',
write  , with
, with  .
Then, just as above,
.
Then, just as above,
 
 
 ,
,  , and repeat until
, and repeat until  .
Soon enough we have computed
.
Soon enough we have computed  .
.  
Here's are two more examples:
 and
 and  .
.
|  |  |  | |
|  |  |  | 
 times as hard'':
 times as hard'':
 and
 and  .
.
|  |  |  | |
|  |  |  | 
With Euclid's algorithm in hand, we can prove that if a prime divides the product of two numbers, then it has got to divide one of them. This result is the key to proving that prime factorization is unique.
 we are done.  If
 we are done.  If  then
 then 
 , since
only
, since
only  and
 and  divide
 divide  .  Stepping through the Euclidean algorithm 
from above, we see that
.  Stepping through the Euclidean algorithm 
from above, we see that 
 At each step, we simply
multiply the equation through by
 At each step, we simply
multiply the equation through by  .  Since
.  Since  and, 
by hypothesis,
 and, 
by hypothesis,  , it follows that
, it follows that 
 .
.
  
 
 
 
 
