Instead of finding the of the smaller number and the remainder of the larger number divided by the smaller number, let the algorithm find the gcd of the difference between the larger number and smaller number AND the remainder of the larger number divided by the smaller number.

In many cases the difference between the larger number and the smaller number is smaller than the smaller number. If it is not, then stick to the original algorithm for that particular instance of the recursion.

This way the Euclidean algorithm will converge twice as fast on the GCD.

### Like this:

Like Loading...

*Related*