Algorithms
A precise, step-by-step procedure. Built from basic steps, repeated steps (for each j …) and conditional steps (only if …). We must justify that it is correct and count how many steps it takes.
Column addition
Align right; add right to left; carry 1 when a column reaches 10 or more (never more than 1, since 9 + 9 + 1 = 19); write the last carry. 473 + 695 = 1168. One more digit = one more column, not 10 times the work.
Divisors and gcd
divisors(n): test j = 1 … n, add j if it divides n. First gcd algorithm: list both, keep common ones, report the rightmost. gcd(375, 825) = 75.
Improvements
One scan to max(m, n) → common divisors up to min(m, n) → keep only most-recent-common-divisor. Still about min(m, n) checks.
Euclid and Āryabhaṭa
- Subtraction: gcd(m, n) = gcd(n, m − n); stop at gcd(m, 0) = m. Slow for gcd(99, 2).
- Division: gcd(m, n) = gcd(n, m mod n). gcd(99, 2) in 2 steps. Long-division chain from the Āryabhaṭīya (499 CE).
History
'Algorithm' comes from Al-Khwārizmī, whose book spread Indian numerals and methods.
Common mistakes
- Forgetting the final carry.
- Writing the sum when a column total is exactly 10 instead of carrying.
- Swapping the order: always reduce to gcd(smaller, remainder).