Fast at last
Division algorithm is efficient
Have we reached the goal?
Our goal since counting dots: an algorithm for gcd whose effort grows with the number of digits, not the value. Euclid's subtraction algorithm needed about 50 reductions for gcd(99, 2).
How many reductions does the division algorithm need for gcd(99, 2)?
What this lesson covers
The idea
The number of reductions in the division algorithm is proportional to the number of digits in m and n.
Have we reached the goal?
Our goal since counting dots: an algorithm for gcd whose effort grows with the number of digits, not the value. Euclid's subtraction algorithm needed about 50 reductions for gcd(99, 2).
How many reductions does the division algorithm need for gcd(99, 2)?
- 2
- About 25
- About 50
Race the two algorithms
Run both algorithms for gcd(375, 825) and compare the reduction counters.
Steps grow with digits
The number of reductions in the division algorithm is proportional to the number of digits in m and n.
gcd(375, 825): subtraction 7 reductions, division 2. gcd(99, 2): subtraction about 50, division 2, and this happens for every problem of the form gcd(2k + 1, 2). The book says the justification is too involved to present here; you will learn it in future grades.
Notes
Āryabhaṭa's division algorithm needs a number of reductions that grows with the number of digits: our goal, reached.
Check yourself
How many reductions does the division algorithm need for gcd(999, 2)?
Answer: 2
gcd(999, 2) → gcd(2, 1) → gcd(1, 0): 2 reductions (subtraction needs about 499).
Why is the division algorithm faster than subtraction?
- One division does the work of many subtractions at once — correct. Yes. m mod n is what many subtractions would leave.
- It skips the stopping rule. It uses the same stopping rule.
- It only works for small numbers. It works for numbers of any size, and that is where it shines.