Euclidean algorithm

This is an old revision of this page, as edited by 195.194.119.220 (talk) at 15:28, 29 September 2006 (Running time). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
This article is not about Euclidean geometry.

In number theory, the Euclidean algorithm (also called Euclid's algorithm) is an algorithm to determine the greatest common divisor (GCD) of two integers or elements of any Euclidean ___domain (for example, polynomials over a field) by repeatedly dividing the two numbers and the remainder in turns. Its major significance is that it does not require factoring the two integers, and it is also significant in that it is one of the oldest algorithms known, dating back to the ancient Greeks.

History of the Euclidean algorithm

The Euclidean algorithm is one of the oldest algorithms known, since it appeared in Euclid's Elements around 300 BC. Euclid originally formulated the problem geometrically, as the problem of finding a common "measure" for two line lengths, and his algorithm proceeded by repeated subtraction of the shorter from the longer segment. However, the algorithm was probably not discovered by Euclid and it may have been known up to 200 years earlier. It was almost certainly known by Eudoxus of Cnidus (about 375 BC); and Aristotle (about 330 BC) hinted at it in his Topics, 158b, 29-35.

this boring and i dont like to do this on my course



This is boring i hate this stuff lol

boring boring broing lol

boring lol

boring

ummmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm boring

PHP/JavaScript implementation

PHP

function gcd($a, $b) {
  if ($b == 0) return $a;
  else return gcd($b, $a % $b);
}

JavaScript

function gcd(var a, var b) {
  if (b == 0) return a;
  else return gcd(b, a % b);
}


See also

References

  • Euclid's Algorithm at cut-the-knot
  • Binary Euclid's Algorithm (Java) at cut-the-knot
  • Euclid's Game (Java) at cut-the-knot
  • Weisstein, Eric W. "Euclidean Algorithm". MathWorld.
  • Euclid's algorithm at PlanetMath.