# Euclid's algorithm in computer science and geometry One of the oldest known algorithms is Euclid's algorithm, we can say for sure because traces and formulas are found in Euclid's Elements, written around 300 BC. This does not assure us that Euclid really discovered it from scratch, he could for example have transcribed it, perhaps refined, but drawing inspiration from his predecessors who had this idea a couple of centuries earlier. L' Euclid's algorithm is an algorithm for finding the greatest common divisor between two integers, the greatest common divisor, it is what the math teacher at school abbreviates with the acronym MCD, capitalized because it is "maximum". It is often cited together with the least common multiple, "lcm", and sometimes even confused. After Euclid, also Eudoxus of Cnidus around 375 BC treated the subject and Aristotle around 330 BC. he mentioned the ne algorithm Topicals.

## Euclid's algorithm: computer science

To use this algorithm often yes they use computer programs. In fact, if we are dealing with small numbers, it is also very easy to use by hand, and practical, but if you want to use it for very large masses of data, such as those that we often find ourselves dealing with today, then computer science gives us a hand by "learning" Euclid's algorithm and applying it in a continuous cycle until you get to provide us with an answer.

There is, again speaking of computers, an alternative algorithm: thebinary MCD algorithm. In this case, to identify the highest common denominator, the binary representation of computers is used which allows us to avoid divisions, increasing efficiency. Returning toEuclid's algorithm, you can use tail recursion to express it and make it "run".

Basically, when we have two natural numbers a and b, we check if b is zero, if it is, it is clear that the GCD is a, if it is not, we divide a / b and see if a remainder is equal to zero or not. If the remainder is zero, b is the GCD, otherwise we proceed by assigning a = b and b = r and repeat the division again. Taking note of the quotients obtained during the development of Euclid's algorithm, we obtain two integers p and q such that ap + bq = GCD (a, b). This is Euclid’s extended algorithm.

There are many occasions when this is possible apply this algorithm, so "simple" but at the same time useful. For example, it has always been used for a long time for some polynomials with one unknown and for homogeneous polynomials with two unknowns and in every context in which it is possible to perform the division with the remainder. By the way, when you have an algebraic object in your hands in which it is possible to divide with the remainder, you have in his hands a "Euclidean ring".

Those who know computer science can also learn more about facial recognition techniques, a very current topic ## Euclid's algorithm: computation time

The calculation time of Euclid's algorithm clearly depends on the values ​​to be managed, from what they are and from how many they are. The type is also important, in some respects, because if two successive Fibonacci numbers are taken as input values, then the calculation time will be very long.

## Geometrical Euclid's algorithm

L'original idea of ​​Euclid however, it is not mathematical, but geometric. Often the graphic representation that geometry uses helps our brain to go further, or to deepen.

In this case it all started from the challenge of wanting find a common "measure" for the length of two segments. Here then is that Euclid's algorithm proceeded by repeatedly subtracting the shortest from the longest, which is exactly what the formula we saw earlier indicates to do. If the numbers become segments, everything is more intuitive.

Euclid's algorithm is one of those discoveries that, once others have made, appears trivial to us. But I challenge anyone to come up with this ai mechanism times of Euclid and with the means he had. ## Euclid's algorithm and Euclid's rhythm

Deepening the algorithm, one also encounters Euclid's rhythm. It is none other than the algorithm, applied to the rhythm of the music. Godfried Toussaint discovered it in 2004, who told it in a document entitled "The Euclidean Algorithm Generates Traditional Musical Rhythms", or "The Euclidean algorithm generates traditional musical rhythms ". What are these numbers for? THE GCD of two numbers it serves from the rhythmic point of view to give the number of beats and silences and generate the most important rhythms of traditional music and of World Music. Almost all of them are based on Euclid's rhythm, except perhaps those of Indian music.