ExamSaathi learning library · Government exams · UPSC CDS Examination (II) 2026, Elementary Mathematics (Arithmetic): elementary number theory, the division algorithm and the Euclidean algorithm · Mathematics
Division algorithm and Euclid's algorithm for the HCF
Write any division of whole numbers as a = bq + r with 0 <= r < b and see why q and r are unique. Sort numbers by remainder, find the HCF by Euclid's repeated division, check it with prime factors and HCF x LCM, and solve largest-divisor questions with given or equal remainders.
Status: original pilot lesson. Teacher review is pending. It is not a complete course or official exam material.
You will learn to
- State the division algorithm a = bq + r with 0 <= r < b for whole numbers, name the dividend, divisor, quotient and remainder, and prove that q and r are unique.
- Write whole numbers in remainder forms such as 3q, 3q + 1 and 3q + 2, or odd numbers as 4q + 1 and 4q + 3, and use them to show that every square leaves remainder 0 or 1 on division by 4.
- Find the HCF of two or three numbers by Euclid's algorithm, using HCF(a, b) = HCF(b, r) until the remainder is 0, and check it by prime factorisation and HCF x LCM = product.
- Solve 'largest number' questions: subtract the given remainders before taking the HCF, or take the HCF of the differences when every remainder is the same.
Before you start
Three ideas from earlier lessons are needed here. From an earlier lesson: one number divides another exactly when the division leaves nothing over, and digit rules for 2, 3, 4, 5, 9 and 11 can show this without long division. From an earlier lesson: every whole number above 1 is a product of primes in only one way if the order of writing is ignored, which is the Fundamental Theorem of Arithmetic. From an earlier lesson: the HCF is the greatest number that goes exactly into each given number, the LCM is their least positive common multiple, and for a pair of numbers HCF x LCM equals their product. Here every number is a whole number (0, 1, 2, 3 and so on) and every divisor is at least 1. When a is divided by b, a is the dividend, b is the divisor, the number of whole times b fits into a is the quotient q, and the amount left over is the remainder r. HCF(a, b) is short for the HCF of a and b. The CDS (II) 2026 notice's syllabus names 'Division algorithm' and 'Euclidean algorithm' in its Elementary Number Theory line, which also lists H.C.F. and L.C.M. For school readers, the CBSE Class IX curriculum for 2026-27 lists the competency 'States and proves remainder theorem, factor theorem, and division algorithm'. There the division algorithm is named next to the remainder theorem, a result about polynomials; this lesson proves its whole-number form.
The division algorithm: a = bq + r with 0 <= r < b
Share Rs 1,000 equally among 7 friends in whole rupees: each gets Rs 142, because 7 x 142 = 994, and Rs 6 is left. In symbols, 1,000 = 7 x 142 + 6. The division algorithm says that such a split always exists and is never ambiguous: for any whole number a and any whole number b of at least 1, there is exactly one pair of whole numbers q and r with a = bq + r and 0 <= r < b. The condition on r carries the weight. The line 1,000 = 7 x 141 + 13 is also true, but 13 cannot be the remainder on division by 7, since another round of Rs 7 could still be handed out. Existence: take b away from a again and again until what is left is smaller than b; the number of subtractions is q, and what is left is r. If a is already smaller than b, then q = 0 and r = a, as in 5 = 7 x 0 + 5. Uniqueness: suppose a = bq + r and also a = bq' + r', with both remainders from 0 to b - 1. Subtracting, b(q - q') = r' - r. The right side lies between -(b - 1) and b - 1, and the only multiple of b in that interval is 0, so r' = r, and then q' = q. This is why we may speak of the remainder, and a remainder of 0 means that b divides a. Wikipedia notes that the statement, sometimes called Euclid's division lemma, is really a theorem; long division is the usual way to find q and r.
Numbers written by their remainders
Because the remainder is unique, a divisor sorts all whole numbers into families. On division by 3 the possible remainders are 0, 1 and 2, so every whole number has exactly one of the forms 3q, 3q + 1 or 3q + 2; for example 27 = 3 x 9, 28 = 3 x 9 + 1 and 29 = 3 x 9 + 2. On division by 2 the forms are 2q, the even numbers, and 2q + 1, the odd numbers. On division by 4 there are four forms: 4q, 4q + 1, 4q + 2 and 4q + 3. The first and third are even, so every odd number is 4q + 1 or 4q + 3, as with 37 = 4 x 9 + 1 and 39 = 4 x 9 + 3. Such forms turn a claim about all numbers into a few lines of algebra. Claim: the square of any whole number leaves remainder 0 or 1 on division by 4. If n is even, n = 2k and n^2 = 4k^2, which leaves 0. If n is odd, n = 2k + 1 and n^2 = 4k^2 + 4k + 1 = 4(k^2 + k) + 1, which leaves 1. So a number that leaves 2 or 3 on division by 4 is never a perfect square. Since 100 = 4 x 25, every full hundred is a multiple of 4, so only the last two digits decide this remainder: 6,183 ends in 83 = 4 x 20 + 3, so 6,183 is not a square. The same method with 3q, 3q + 1 and 3q + 2 shows that a square leaves remainder 0 or 1 on division by 3 as well.
Euclid's algorithm: HCF(a, b) = HCF(b, r)
Euclid's algorithm finds an HCF by division alone, with no factorising. It rests on one fact: if a = bq + r, then HCF(a, b) = HCF(b, r). Any number that divides both a and b also divides r = a - bq, and any number that divides both b and r also divides a = bq + r. So the pairs (a, b) and (b, r) share exactly the same common divisors, and hence the same greatest one. Divide the larger number by the smaller, then divide the last divisor by the last remainder, and repeat until a remainder is 0. The divisor in that last division is the HCF, because HCF(d, 0) = d; it is the last non-zero remainder, or b itself when b divides a at the first step. For 612 and 270: 612 = 270 x 2 + 72, 270 = 72 x 3 + 54, 72 = 54 x 1 + 18 and 54 = 18 x 3 + 0, so HCF(612, 270) = 18. On a floor 612 cm by 270 cm, the steps cut off two 270 cm squares, then three 72 cm squares, then one 54 cm square, and three 18 cm squares fill the rest, so 18 cm tiles cover the floor exactly. The remainders fall at every step, so the process must stop. For three numbers, find the HCF of two and then its HCF with the third. Wikipedia's article on the algorithm places it in Book VII of Euclid's Elements (about 300 BC), where it is stated for whole numbers, and adds that Aryabhata described it in the late fifth century, calling it the 'pulverizer'.
Checking an HCF, and two remainder questions
Check an HCF in three ways. It must divide both numbers: 612 = 18 x 34 and 270 = 18 x 15. Prime factors must agree: 612 = 2^2 x 3^2 x 17 and 270 = 2 x 3^3 x 5 share 2 x 3^2 = 18. And for two numbers HCF x LCM = product, so LCM = 612 x 270 / 18 = 9,180, which must be a multiple of each number: 9,180 = 612 x 15 = 270 x 34. The same algorithm settles two kinds of remainder question. Type 1 asks for the largest number that divides given numbers leaving given remainders. If N leaves remainder r on dividing n, then N divides n - r exactly. So subtract each remainder from its own number, take the HCF of the results, and confirm that the answer is larger than every remainder, because a remainder is always smaller than its divisor; uniqueness then makes each given remainder the true one. Type 2 asks for the largest number that leaves the same remainder on dividing each given number. If n1 = Nq1 + r and n2 = Nq2 + r, then n2 - n1 = N(q2 - q1), so N divides every difference; conversely, any N that divides all the differences leaves the same remainder on every number. Take the HCF of the differences, then divide any one number by it to read the common remainder. With three numbers two differences are enough, because the third is their sum. In both types the answer is an HCF, never an LCM: the question wants a divisor, not a common multiple.
Common mistakes
First, stopping one step early. A small remainder is not the HCF until the next division leaves 0: with 612 and 270, the remainder 54 is not the answer, because 72 = 54 x 1 + 18 still leaves 18. Second, carrying the quotient instead of the remainder. After 612 = 270 x 2 + 72, the next division is 270 by 72, not 270 by 2; the quotients only count how often a number fits and never enter the HCF. Third, accepting a 'remainder' that is not smaller than the divisor, as in 1,000 = 7 x 141 + 13; keep dividing until r is less than b. Fourth, forgetting to subtract the remainders in a type 1 question. The divisor goes exactly into n - r, not into n, so the HCF of the given numbers is the wrong target; in worked example 2 it is just 1. Take each remainder off its own number, and reject an answer that is not larger than every remainder. Fifth, in a type 2 question, taking the HCF of the numbers themselves instead of their differences, or reporting the common remainder as the divisor. Sixth, using the LCM where the HCF is asked: 'the largest number that divides' calls for an HCF, while 'the smallest number that each one divides' calls for an LCM. Last, HCF x LCM = product holds for two numbers only: 6, 10 and 15 have HCF 1 and LCM 30, but their product is 900.
A step list for remainder and HCF questions
1. Write each division as a = bq + r and check that 0 <= r < b. If r is too large, the quotient is too small, so raise it. 2. To sort numbers by remainder, fix the divisor and list its forms, such as 3q, 3q + 1 and 3q + 2, or 4q + 1 and 4q + 3 for odd numbers. Prove the claim for each form in turn. 3. For an HCF by Euclid's algorithm, divide the larger number by the smaller, then shift along: the divisor becomes the new dividend and the remainder the new divisor, so (a, b) becomes (b, r). 4. Stop only when a remainder is 0; the divisor in that last division, normally the last non-zero remainder, is the HCF. 5. For three or more numbers, take the HCF of two, then of that answer and the next number. 6. Check the HCF: it divides every number, it matches the shared prime factors, and for two numbers HCF x LCM equals their product, which also gives the LCM. 7. Different remainders: subtract each remainder from its own number, take the HCF, and confirm that the answer exceeds every remainder. 8. Equal remainders: take the HCF of the differences, then divide one number by it to find the remainder. 9. Finally, divide each given number by your answer and see that the stated remainders come out.
Worked examples
A textile unit in Surat has two lengths of cloth, 7,686 cm and 1,449 cm, to be cut into pieces of one common length, as long as possible, with nothing left over. Find that length by Euclid's algorithm and the number of pieces. Then check the HCF by prime factorisation, and use HCF x LCM = product to find the LCM of 7,686 and 1,449.
- Step 1: The piece length must divide both lengths exactly and be as long as possible, so it is HCF(7,686, 1,449).
- Step 2: 7,686 = 1,449 x 5 + 441, since 1,449 x 5 = 7,245 and 7,686 - 7,245 = 441. So HCF(7,686, 1,449) = HCF(1,449, 441).
- Step 3: 1,449 = 441 x 3 + 126, since 441 x 3 = 1,323. So the HCF equals HCF(441, 126).
- Step 4: 441 = 126 x 3 + 63, since 126 x 3 = 378. So the HCF equals HCF(126, 63).
- Step 5: 126 = 63 x 2 + 0. The remainder is 0, so the last non-zero remainder, 63, is the HCF. The pieces are 63 cm long, and there are 7,686 / 63 + 1,449 / 63 = 122 + 23 = 145 of them.
- Step 6: Check by prime factors: 7,686 = 2 x 3^2 x 7 x 61 and 1,449 = 3^2 x 7 x 23, which share 3^2 x 7 = 63.
- Step 7: LCM = 7,686 x 1,449 / 63 = 7,686 x 23 = 176,778. The prime factors agree, since 2 x 3^2 x 7 x 23 x 61 = 176,778, and 63 x 176,778 = 11,137,014 = 7,686 x 1,449.
Answer: Each piece is 63 cm long and there are 145 pieces. HCF(7,686, 1,449) = 63, the LCM is 176,778, and 63 x 176,778 = 11,137,014 = 7,686 x 1,449.
A sweet shop in Agra has 1,159 pedas, 1,379 barfis and 1,699 laddoos. It packs each kind separately in boxes that all hold the same number of sweets, filling as many boxes as possible, and is left with 7 pedas, 11 barfis and 19 laddoos. What is the largest number of sweets a box can hold, and how many boxes are filled?
- Step 1: The box size N goes exactly into the sweets that were packed: 1,159 - 7 = 1,152, 1,379 - 11 = 1,368 and 1,699 - 19 = 1,680. Each leftover is a remainder, so N must also be larger than 19.
- Step 2: Euclid's algorithm on the first two: 1,368 = 1,152 x 1 + 216; 1,152 = 216 x 5 + 72; 216 = 72 x 3 + 0. So HCF(1,368, 1,152) = 72.
- Step 3: Bring in the third number: 1,680 = 72 x 23 + 24; 72 = 24 x 3 + 0. So the HCF of 1,152, 1,368 and 1,680 is 24.
- Step 4: 24 is larger than 19, so it is a valid box size. Check: 1,159 = 24 x 48 + 7, 1,379 = 24 x 57 + 11 and 1,699 = 24 x 70 + 19.
- Step 5: The boxes filled are 48 + 57 + 70 = 175.
- Step 6: Two tempting wrong answers fail. Boxes of 72 suit the pedas and barfis, but 1,699 = 72 x 23 + 43 would leave 43 laddoos, not 19. The HCF of 1,159, 1,379 and 1,699 themselves is 1, because it ignores the leftovers.
Answer: A box can hold at most 24 sweets, and 175 boxes are filled: 48 of pedas, 57 of barfis and 70 of laddoos.
A dairy in Anand receives 1,217 litres, 1,657 litres and 2,217 litres of milk from three villages. Each lot is poured into cans of one size, filling as many cans as possible, and every lot leaves the same quantity of milk over. Find the largest possible capacity of a can and the quantity left over from each lot.
- Step 1: If a can holds N litres and each lot leaves r litres, then N goes exactly into the differences between the lots: 1,657 - 1,217 = 440 and 2,217 - 1,657 = 560. The third difference, 2,217 - 1,217 = 1,000, equals 440 + 560, so it adds nothing new.
- Step 2: Euclid's algorithm: 560 = 440 x 1 + 120; 440 = 120 x 3 + 80; 120 = 80 x 1 + 40; 80 = 40 x 2 + 0. So HCF(560, 440) = 40.
- Step 3: Divide one lot by 40 to find the leftover: 1,217 = 40 x 30 + 17. Check the others: 1,657 = 40 x 41 + 17 and 2,217 = 40 x 55 + 17.
- Step 4: The leftover 17 is less than 40, as a remainder must be. Smaller cans whose size divides 40, such as 20 litres, also leave equal amounts, but 40 litres is the largest size that does.
Answer: The largest can holds 40 litres, and each lot leaves 17 litres over (after 30, 41 and 55 full cans).
Practice checks
- Students of a school in Mysuru line up for assembly in rows of 36, and the last row has only 29 students. If they line up in rows of 12 instead, how many students stand in the last, incomplete row?
- Meera from Shillong says that exactly one of these numbers is a perfect square. Using remainders on division by 4, which one must it be?
- Two coils of cable at a metro site in Bengaluru are 3,813 m and 1,178 m long. Both are to be cut into pieces of one length, as long as possible, with nothing left over. Using Euclid's algorithm, how long is each piece?
- A bangle seller in Hyderabad packs 578 red, 763 green and 1,230 gold bangles in boxes that all hold the same number, one colour to a box, filling as many boxes as possible. She has 2 red, 7 green and 6 gold bangles left over. What is the largest number of bangles a box can hold?
- A printing press in Guwahati has three paper rolls, 2,171 m, 2,668 m and 3,094 m long. Each roll is cut into as many pieces of one length as possible, and the same length is left over from every roll. What is the greatest possible length of a piece?
Sources checked
- Union Public Service Commission, Examination Notice No. 11/2026-CDS-II dated 20.05.2026: Combined Defence Services Examination (II), 2026 — Appendix-I (The scheme, standard and syllabus of the examination), B. Standard and Syllabus of the Examination, Syllabus, Elementary Mathematics (Code No. 13), Arithmetic (PDF page 20): 'Elementary Number Theory—Division algorithm. Prime and composite numbers. Tests of divisibility by 2, 3, 4, 5, 9 and 11. Multiples and factors. Factorisation Theorem. H.C.F. and L.C.M. Euclidean algorithm.' Only the one-line mention in 'Before you start' relies on this notice: it reports that the syllabus line names the division algorithm and the Euclidean algorithm beside H.C.F. and L.C.M.
- CBSE Mathematics, Class IX (2026-27) curriculum — Curricular Goals (CGs) and Competencies (Cs) from the NCF-SE 2023, under CG-3 (PDF page 2): 'C-3.1 States and proves remainder theorem, factor theorem, and division algorithm.' Quoted in 'Before you start' as a school bridge only. The remainder theorem and the factor theorem are results about polynomials, so this is not a claim that the board teaches this lesson; the lesson states and proves the whole-number form of the division algorithm (a quotient and remainder exist and are unique) in 'The division algorithm: a = bq + r with 0 <= r < b'.
- CBSE Mathematics, Class X (2026-27) curriculum — Course structure, UNIT I: NUMBER SYSTEMS, 1. REAL NUMBERS (PDF page 3): '1. Fundamental Theorem of Arithmetic - statements after reviewing work done earlier and after illustrating and motivating through examples'. A bridge for the prime-factor check: the lesson recaps the theorem in 'Before you start' and uses unique prime factorisation to confirm an HCF and an LCM in 'Checking an HCF, and two remainder questions' and in worked example 1. The unit does not name the division algorithm or Euclid's algorithm.
- Wikipedia, Euclidean algorithm (encyclopedia article) — Lead, 'Background: greatest common divisor', 'Procedure', 'Proof of validity', 'Visualization' and 'Historical development': HCF is listed among the other names of the GCD; each step swaps the pair for the smaller number and the remainder without changing the GCD, the remainders keep falling so the method ends, and the last non-zero remainder is the GCD; the steps can be pictured as cutting square tiles from a rectangle; the method is in Book 7 of Euclid's Elements (c. 300 BC) for whole numbers; Aryabhata described it in the late 5th century as the 'pulverizer'. Supports 'Euclid's algorithm', including its history sentence, and worked examples 1 to 3.
- Wikipedia, Euclidean division (encyclopedia article) — Lead, 'Division theorem', 'Intuitive example' and 'Proof' (existence and uniqueness): for a non-zero divisor there is exactly one quotient and one remainder, the remainder being at least 0 and below the size of the divisor; the four names dividend, divisor, quotient and remainder; the result is sometimes called Euclid's division lemma and, although it is a theorem, is often called the division algorithm; existence by repeated subtraction and uniqueness by comparing two divisions. Supports 'The division algorithm' section and practice question 1.
- Wikipedia, Greatest common divisor (encyclopedia article) — Lead, Definition, 'Using prime factorizations', 'Euclid's algorithm', 'Euclidean algorithm' and Properties: highest common factor (HCF) is another name for the GCD; gcd(a, 0) = a is where the Euclidean algorithm stops; replacing a by its remainder on division by b keeps the GCD; Euclid's own version subtracted the smaller number from the larger; the GCD from the lower powers of the shared primes; gcd(a, b) x lcm(a, b) = a x b. Supports 'Euclid's algorithm', the checks in 'Checking an HCF, and two remainder questions' and the LCM in worked example 1.
- Wikipedia, Remainder (encyclopedia article) — Lead, 'Integer division' and 'Polynomial division': in integer division the remainder is the unique r with 0 <= r below the size of the divisor (the least positive remainder); dividing a polynomial f(x) by x - k leaves the remainder f(k), the polynomial remainder theorem. Supports the meaning of 'remainder' used throughout and the remark in 'Before you start' that the remainder and factor theorems concern polynomials.
- Wolfram MathWorld (Eric W. Weisstein), Euclidean Algorithm — Opening paragraphs: Euclid's algorithm finds the greatest common divisor of two numbers by taking remainders of consecutive terms, the larger number written first, and for integers it ends when a remainder divides the term before it exactly; the version for whole and rational numbers is in Book VII of Euclid's Elements. Supports the procedure and the Book VII remark in 'Euclid's algorithm'.
- MacTutor History of Mathematics (University of St Andrews), Euclid of Alexandria, biography — Biography, the account of the Elements: the Elements has 13 books, Books 7 to 9 treat number theory, and Book 7 contains the Euclidean algorithm for the greatest common divisor of two numbers; the biography also says that very little is known of Euclid's life. Used to confirm the Book VII remark in 'Euclid's algorithm'; no other biographical claim is made in the lesson.
- Cut-the-knot (Alexander Bogomolny), Euclid's Algorithm — Opening section and first example: the algorithm answers Proposition VII.2 of the Elements, on the greatest common measure of two numbers; it rests on two facts, that gcd(a, b) = b when b divides a and that a = bt + r gives gcd(a, b) = gcd(b, r), because every common divisor of one pair divides the other pair; a chain of divisions ends when a division is exact. Supports the key fact, its proof and the stopping rule in 'Euclid's algorithm'.
- Brilliant Math and Science Wiki, Division Algorithm — 'What is the Algorithm?' and 'Extensions': divide by subtracting the divisor again and again, so that the count of subtractions is the quotient and what is left, from 0 up to just below the divisor, is the remainder; quotient and remainder are unique; Euclid's algorithm repeats the division algorithm using gcd(a, b) = gcd(b, r); two numbers that leave one remainder on division by 7 behave alike. Supports the existence argument in 'The division algorithm', the key fact in 'Euclid's algorithm' and the type 2 reasoning in the fourth teaching section.
- Brilliant Math and Science Wiki, Greatest Common Divisor — 'Computing the greatest common divisor' and 'Euclidean algorithm and more': the GCD from prime factorisations using the smallest exponent of each shared prime; gcd(a, b, c) = gcd(gcd(a, b), c), so three numbers can be handled two at a time; the subtraction form of Euclid's method. Supports the three-number step in 'Euclid's algorithm', worked example 2 and practice question 4.
- OpenStax (Rice University), Contemporary Mathematics, 3.1 Prime and Composite Numbers, open textbook — 'Finding the Prime Factorization of Composite Numbers', 'Finding the Greatest Common Divisor', 'Applications of the Greatest Common Divisor' and 'Finding the Least Common Multiple': the Fundamental Theorem of Arithmetic; the GCD as the product of the common prime factors with their smallest exponents; the LCM from every prime with its largest exponent; GCD problems about equal square tiles and equal groups. Supports the prime-factor checks in the fourth teaching section and worked example 1, and the cutting and packing settings of the worked examples.