An algorithm in math is a finite sequence of step-by-step instructions that solves a specific problem or performs a calculation. Every algorithm takes an input, follows a defined set of operations in order, and produces an output. You already use algorithms regularly: long division, for example, is an algorithm. So is any method you were taught for multiplying large numbers by hand. The concept is simple, but it underpins everything from basic arithmetic to modern encryption.
What Makes Something an Algorithm
Not every set of instructions qualifies. Computer scientist Donald Knuth identified the properties that separate a true algorithm from a vague procedure. First, it must be finite: the steps have to end. A process that could loop forever isn’t an algorithm. Second, every step must be precisely defined, with no room for interpretation. “Add 3 to x” is definite. “Pick a number that feels right” is not.
An algorithm also needs at least one output, some result that relates to the input you started with. And every operation in the sequence must be something that can actually be carried out. You can’t include a step like “divide by zero” or “find the exact value of pi” because those can’t be completed. Think of it like a recipe: you need a list of ingredients (input), clear cooking instructions (steps), and a finished dish (output). If any step is ambiguous or impossible, the recipe fails.
Where the Word Comes From
The word “algorithm” traces back over 1,000 years to the Persian mathematician Muhammad ibn Mūsā al-Khwārizmī, who lived from 780 to 850 CE during the Islamic Golden Age. Around 830 CE, he wrote a treatise on algebra called “Al-Jabr” (which also gave us the word “algebra”). A separate work introduced Hindu-Arabic numerals to the Western world and was translated into Latin under the title “Algoritmi de Numero Indorum.” That Latinized version of his name, “Algoritmi,” eventually became “algorithm.”
Algorithms You Already Know
Long division is one of the most familiar mathematical algorithms. You divide, multiply, subtract, bring down the next digit, and repeat. Each cycle follows the exact same steps, and you keep going until there are no more digits to bring down. The process always terminates, every step is unambiguous, and you get a definite answer at the end. That repetitive, mechanical quality is the hallmark of an algorithm.
The multiplication method you learned in school works the same way: multiply each digit, carry values, shift rows, then add. These procedures feel routine, but they meet every formal requirement. They’re finite, definite, and guaranteed to produce the correct result for any valid input.
The Euclidean Algorithm
One of the oldest and most elegant algorithms in mathematics finds the greatest common divisor (GCD) of two numbers, meaning the largest number that divides evenly into both. The Euclidean algorithm, dating back to ancient Greece, works by repeated division.
Say you want the GCD of 252 and 105. Divide 252 by 105 to get a remainder of 42. Now divide 105 by 42 to get a remainder of 21. Divide 42 by 21, and the remainder is 0. The last nonzero remainder, 21, is the GCD. The key insight is that the remainder shrinks with every step, so the process always reaches zero and always terminates. This algorithm is still used today in cryptography and computer science, not just as a historical curiosity.
The Sieve of Eratosthenes
Finding prime numbers seems like it should require testing each number individually, but the Sieve of Eratosthenes offers a faster systematic approach. To find every prime up to, say, 50, you start by listing all integers from 2 to 50. The first number, 2, is prime. Cross out every multiple of 2 (4, 6, 8, 10…) because they’re not prime. The next uncrossed number is 3, which is prime. Cross out every multiple of 3. The next surviving number is 5, so cross out multiples of 5. Continue until there are no more numbers to process. Every number still standing at the end is prime.
No complicated calculations are needed at any step. You’re just counting forward and crossing things off. That simplicity is what makes it a powerful algorithm: a mechanical process that anyone can follow to get a guaranteed correct result.
Algorithms vs. Approximate Methods
In math, a true algorithm guarantees the correct answer every time. This distinguishes it from what mathematicians call heuristics, which are shortcut methods that find approximate or “good enough” solutions. A heuristic might get close to the best answer quickly, but it can’t prove it found the optimal one. Run the same heuristic twice and you might get two different results.
Algorithms, by contrast, are deterministic. Given the same input, they always produce the same output, and that output is provably correct. The tradeoff is time: an exact algorithm might take much longer to run than an approximate method, especially for large, complex problems. In practice, many real-world applications use heuristics when the exact algorithm would take too long, accepting a “close enough” answer. But in pure mathematics, the guarantee of correctness is what gives algorithms their power.
How Algorithms Power Modern Math
Mathematical algorithms aren’t just classroom exercises. The encryption protecting your online banking relies on algorithms rooted in number theory. The RSA cryptosystem, one of the most widely used encryption methods, works by multiplying two enormous prime numbers together. Encrypting a message requires only that product and a public key. Decrypting it requires knowing the original two primes. The security holds because no known algorithm can efficiently factor a huge number back into its prime components. The Euclidean algorithm plays a direct role here too, helping generate the mathematical keys needed for encryption and decryption.
Optimization problems use algorithms as well. When a shipping company needs to minimize delivery costs across hundreds of routes with constraints on fuel, time, and vehicle capacity, algorithms from a branch of math called linear programming find the exact best solution by systematically moving between possible answers until no better option exists.
At every level, from elementary arithmetic to cutting-edge cryptography, algorithms provide the same thing: a reliable, repeatable procedure that transforms a question into an answer.

