That's a fantastic question that gets to the very heart of mathematics and computer science history.
While people have used step-by-step procedures for thousands of years, the title of the oldest known non-trivial algorithm is most often given to:
Euclid's Algorithm
What is Euclid's Algorithm?
- Purpose: To find the greatest common divisor (GCD) of two integers. The GCD is the largest number that divides both integers without leaving a remainder.
- Origin: It's described in Euclid's Elements, written around 300 BC in ancient Greece.
- Why it's so important: It is a remarkably efficient and elegant algorithm that is still a fundamental part of number theory and computer science today. It's used in cryptography (like the RSA algorithm) and many other computational tasks.
Here's how it works with an example (finding the GCD of 252 and 105):
- Divide 252 by 105. It goes in 2 times with a remainder of 42. (252 = 2 * 105 + 42)
- Now, take the previous divisor (105) and the remainder (42) and repeat. Divide 105 by 42. It goes in 2 times with a remainder of 21. (105 = 2 * 42 + 21)
- Repeat again. Divide 42 by 21. It goes in 2 times with a remainder of 0.
- Once you reach a remainder of 0, the last non-zero remainder is the answer.
The GCD of 252 and 105 is 21.
But... Are There Older Candidates?
This is where the definition of "algorithm" gets interesting. If we define an algorithm as any explicit step-by-step procedure for calculation, then there are much older examples.
1. Babylonian Algorithms (c. 1800-1600 BC)
Ancient Babylonian clay tablets contain some of the earliest evidence of systematic procedures for solving mathematical problems. For example:
- Square Root Approximation: The famous YBC 7289 tablet shows a method for approximating the square root of 2. This is an iterative method, a key concept in algorithms.
- Solving Quadratic Equations: They had step-by-step recipes for solving problems that would be equivalent to our quadratic equations.
These procedures are over 1,300 years older than Euclid's work!
2. Egyptian Algorithms (c. 1650 BC)
The Rhind Mathematical Papyrus from ancient Egypt describes several procedures, most notably:
- Ancient Egyptian Multiplication: A method for multiplying two numbers that only requires the ability to add and double numbers. It works by expressing one number in a binary-like form. This method is a clear, step-by-step process that always yields the correct result.
The Verdict: Why Euclid's Algorithm Usually Wins
Even though the Babylonian and Egyptian procedures are older, Euclid's algorithm is typically given the title for a few key reasons:
- Generality and Abstraction: The Babylonian and Egyptian methods were often presented as recipes to solve a specific problem. Euclid's algorithm was presented as a general method that works for any pair of integers, complete with a proof of its correctness.
- Non-Triviality: While clever, the Egyptian multiplication method is an arithmetic shortcut. Euclid's algorithm solves a more abstract problem in number theory with a surprisingly clever logical leap.
- Formalization: It was part of Euclid's Elements, one of the most rigorous and influential works in the history of mathematics. It represents one of the first examples of true algorithmic thinking within a formal logical system.
In summary:
- For the oldest known mathematical procedures, the prize goes to the Babylonians.
- For the oldest known non-trivial, general-purpose algorithm that feels modern in its logic and proof, the title almost always goes to Euclid's algorithm.