Step |
Task |
1 |
Assign the value of the larger number to M, and the smaller number to N |
2 |
Divide M by N (M/N) and assign the remainder to R |
3 |
If R is not 0, then assign M the value of N, assign N the value of R, and return to step 2 If R = 0, then the GCD is N and the algorithm terminates |
Notice that in Step 3 there are two different possibilities. This is typically how algorithms work. There usually needs to be some terminating condition, otherwise the algorithm (program) runs forever.