Faster Euclidean Algorithm

Instead of finding the gcd 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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s