Saraswati Vidyamandir Logo
Home Our Courses CBSE Resources
NCERT Solutions
Science — Class 9 Science — Class 10 Maths — Class 9 Maths — Class 10 About Us Contact Us Book Free Orientation
11

The World of Algorithms

Class 9 Maths (Ganita Manjari Part 2)  ·  NCERT Solutions 2026–27  ·  15 Questions

15 Questions Solved
Complete, step-by-step NCERT Solutions for Class 9 Maths Chapter 11 — The World of Algorithms from the 2026–27 Ganita Manjari textbook, Part 2. The chapter treats familiar procedures — column addition, listing divisors, finding the gcd — as algorithms: exact step-by-step instructions that can be executed, checked and improved, ending with Euclid’s algorithm and Āryabhaṭa’s division method. Every question from Exercise Sets 11.1 to 11.3 and the End-of-Chapter Exercises is solved with a step-by-step trace of each algorithm, and every answer has been checked by running the algorithm on the book’s numbers and on dozens of random inputs. Questions marked * carry an asterisk in the book. Prepared by the faculty at Saraswati Vidyamandir, Ambala Cantt.

Exercise Set 11.1

Q1

Add two 4-digit numbers using the steps we have written down. Make sure you follow the steps precisely; do not perform any action that is not explicitly mentioned. Are you able to obtain the correct result?

Answer

Here are the steps exactly as the book gives them:

Algorithm to add two numbers (as printed in the book)
  1. Write the numbers one below the other so that the digits are aligned from right to left.
  2. Add the rightmost digits.
    • If the sum is less than 10, write the sum below the two digits. Set carry to 0.
    • If the sum is more than 10, write the units digit of the sum below the two digits. Set carry to 1.
  3. Move to the next column on the left. Add the two digits and the current value of carry.
    • If the sum is less than 10, write the sum. Set carry to 0.
    • If the sum is more than 10, write the units digit of the sum. Set carry to 1.
  4. Repeat Step 3 until there are no more digits on the left.
  5. If the value of carry is 1, write 1 to the left of the bottom row.

Example 1: 4738 + 2596. Write 4738 on top and 2596 below it, units under units (Step 1). Then:

ColumnWorkingAction
Units
(Step 2)
8 + 6 = 14write 4,
carry 1
Tens
(Step 3)
3 + 9 + 1 = 13write 3,
carry 1
Hundreds
(Step 3)
7 + 5 + 1 = 13write 3,
carry 1
Thousands
(Step 3)
4 + 2 + 1 = 7write 7,
carry 0

Step 5: the carry is now 0, so nothing more is written. Reading the bottom row from left to right gives 7334, and \(4738 + 2596 = 7334\) is correct. So for these numbers, yes, the steps work.

Example 2: 3645 + 2465. Step 2 adds the rightmost digits:

\(5 + 5 = 10\)

Now read the two rules in Step 2 carefully. One is for a sum less than 10 and the other is for a sum more than 10. A sum of exactly 10 is neither, so the steps tell us nothing: we do not know what to write or what the carry should be. If we follow the steps precisely, we get stuck and cannot finish (the correct answer is 6110).

The same thing happens in Step 3 whenever two digits and the carry add up to exactly 10, for example \(4 + 5 + 1 = 10\).

Answer: we get the correct result only when no column adds up to exactly 10. To mend the algorithm, change “more than 10” to “10 or more” in both Step 2 and Step 3. With that change, 3645 + 2465 runs through to 6110.

This is the lesson of the question: a computer, or a person following the steps exactly, does only what is written. A gap that a human fills in without noticing (here, the case of exactly 10) is a real error in the algorithm.
Q2

What happens if you add a 5-digit number to a 3-digit number. Do our steps handle this situation correctly?

Answer

Take 52817 + 694. Write 694 under the last three digits of 52817 (Step 1).

ColumnWorkingAction
Units
(Step 2)
7 + 4 = 11write 1,
carry 1
Tens
(Step 3)
1 + 9 + 1 = 11write 1,
carry 1
Hundreds
(Step 3)
8 + 6 + 1 = 15write 5,
carry 1

Now Step 4 says to repeat Step 3, because 52817 still has digits on the left. But Step 3 says “add the two digits and the carry”, and in the thousands column there is only one digit (2); the lower number has run out. The steps do not say what to do, so as written they do not handle this case.

The natural fix is to treat a missing digit as 0 (as if 694 were written 00694). With that change:

ColumnWorkingAction
Thousands
(Step 3)
2 + 0 + 1 = 3write 3,
carry 0
Ten‑thou­sands
(Step 3)
5 + 0 + 0 = 5write 5,
carry 0

Step 5: the carry is 0. The bottom row reads 53511, and indeed \(52817 + 694 = 53511\).

So the steps work for numbers of different lengths only after we add one more instruction: “if one number has no digit in a column, use 0 for it”.

Q3

Why is it important to align the columns from right to left?

Answer

The value of a digit depends on its place. Aligning from the right puts units under units, tens under tens, hundreds under hundreds, so each column adds digits of the same place value, and a carry of 1 from one column is exactly one unit of the next place.

If we aligned from the left instead, two numbers of different lengths would line up wrongly. For 473 + 25:

Aligned fromWhat is really added
the right473 + 25 = 498 (correct)
the left473 + 250 = 723 (wrong)

Lined up from the left, the 2 of 25 sits under the 4 (hundreds) and the 5 under the 7 (tens), so 25 has been read as 2 hundreds and 5 tens, that is 250. Aligning from the right is what makes every column add like with like.

Q4

In Step 3, why cannot the value of carry be more than 1?

Answer

Each digit is at most 9. In Step 2 (the units) there is no carry yet, so the largest possible sum is

\(9 + 9 = 18\)

which is less than 20, so its tens digit is at most 1. The carry passed to the next column is therefore 0 or 1.

In Step 3 we add two digits and that carry. The largest possible sum is

\(9 + 9 + 1 = 19\)

again less than 20, so the new carry is again at most 1. Since the carry starts at 0 or 1 and every column passes on 0 or 1, the carry can never be more than 1, however long the numbers are.

The carry would be bigger if we added three or more numbers in one go: \(9 + 9 + 9 = 27\) gives a carry of 2.
Q5

What happens if we do not include the fifth step in the algorithm above? Give examples where the algorithm will work correctly and where it will fail to work.

Answer

Step 5 writes the last carry. Without it, a carry produced by the leftmost column is simply lost.

Works: 473 + 215.

ColumnWorkingAction
Units
(Step 2)
3 + 5 = 8write 8,
carry 0
Tens
(Step 3)
7 + 1 + 0 = 8write 8,
carry 0
Hundreds
(Step 3)
4 + 2 + 0 = 6write 6,
carry 0

The final carry is 0, so Step 5 would have done nothing anyway. Result 688, correct.

Fails: 473 + 695 (the book’s own example).

ColumnWorkingAction
Units
(Step 2)
3 + 5 = 8write 8,
carry 0
Tens
(Step 3)
7 + 9 + 0 = 16write 6,
carry 1
Hundreds
(Step 3)
4 + 6 + 1 = 11write 1,
carry 1

The bottom row reads 168 and the final carry of 1 is never written. The answer comes out as 168 instead of 1168.

Rule: without Step 5 the algorithm is correct exactly when the leftmost column adds up to less than 10 (no carry out of it), and wrong whenever the answer has one more digit than the longer number.

Exercise Set 11.2

Q1

Suppose List 1 and List 2 are two lists of numbers in increasing order.

(i)Write an algorithm to find elements in List 1 that are not present in List 2.
(ii)Write an algorithm to find elements in List 2 that are not present in List 1.
Answer

(i) This is the gcd algorithm’s “common divisors” step turned round: instead of keeping the elements that do appear in the other list, we keep the ones that do not.

Algorithm: elements of List 1 not in List 2
  1. Start with an empty list only-in-1.
  2. For each number x in List 1:
    • if x does not appear in List 2, add x to only-in-1.
  3. Report only-in-1.

Trace with List 1 = divisors(375) = [1, 3, 5, 15, 25, 75, 125, 375] and List 2 = divisors(825) = [1, 3, 5, 11, 15, 25, 33, 55, 75, 165, 275, 825]:

x in List 1In List 2?only-in-1
1yes[]
3yes[]
5yes[]
15yes[]
25yes[]
75yes[]
125no[125]
375no[125, 375]

Result: [125, 375].

Because both lists are in increasing order, we need not search the whole of List 2 for every x. We can walk through both lists together, once, as when merging two sorted lists:

Faster version, using the increasing order
  1. Start with an empty list only-in-1. Point at the first element of each list.
  2. While List 1 has elements left, compare x (List 1) with y (List 2):
    • if List 2 is used up or x < y: x is not in List 2, add x and move to the next x;
    • if x = y: x is in List 2, move on in both lists;
    • if x > y: move to the next y.
  3. Report only-in-1.

The simple version checks every x against every y; the faster one looks at each element of each list only once. Both give the same list, and the result is again in increasing order.

(ii) Exactly the same algorithm with the roles of the lists swapped: for each number y in List 2, if y does not appear in List 1, add y to only-in-2. For the lists above this gives [11, 33, 55, 165, 275, 825].

Q2

Describe an algorithm to compute the least common multiple (lcm) of two numbers.

Answer

The lcm is the smallest number that both m and n divide. Every common multiple is a multiple of the larger number, so we only need to test the multiples of the larger number, in increasing order, and stop at the first one that the smaller number divides.

Algorithm to find lcm(m, n)
  1. If m < n, swap them, so that m is the larger number.
  2. For each j in the sequence 1, 2, 3, …, n:
    • if n divides m × j, report m × j as lcm(m, n) and stop.

It always stops by \(j = n\) at the latest, because \(m \times n\) is a common multiple of m and n.

Trace for lcm(375, 825): the larger number is 825.

j825 × jDoes 375 divide it?
1825no
21650no
32475no
43300no
54125yes — stop

So lcm(375, 825) = 4125, found after checking 5 multiples.

A faster way, using gcd. For any two numbers,

\(\text{lcm}(m, n) = \dfrac{m \times n}{\gcd(m, n)}\)

With gcd(375, 825) = 75 from the chapter, keep the product unevaluated and cancel first:

\(\text{lcm}(375, 825) = \dfrac{375 \times 825}{75}\)
\(= 5 \times 825\)
\(= 4125\)

This version needs only a gcd (which Euclid’s algorithm finds quickly), one multiplication and one division.

Q3

* Divisors occur in pairs. For instance, the divisors of 18 are (1, 18), (2, 9) and (3, 6).

(i)If we write out divisors in pairs, how many numbers do we have to examine between 1 and \(n\) to find all the divisors of \(n\)?
(ii)If we list out the divisors in pairs, will our gcd algorithm still work in the manner we have described?
Answer

(i) If \(j\) divides \(n\), then so does \(n \div j\), and the two form a pair \(j \times (n \div j) = n\). In every pair the smaller number is at most \(\sqrt n\): if both were bigger than \(\sqrt n\), their product would be bigger than \(n\). So it is enough to examine \(j = 1, 2, 3, \ldots\) only while \(j \times j \le n\), and for each \(j\) that divides \(n\), write down the pair \((j,\ n \div j)\).

Trace for n = 18:

jj × j ≤ 18?Pair found
11, yes(1, 18)
24, yes(2, 9)
39, yes(3, 6)
416, yesnone
525, no: stop—

(4 does not divide 18, so it gives no pair.) Only 4 numbers were examined instead of 18. In general we examine about \(\sqrt n\) numbers, the whole numbers from 1 up to \(\sqrt n\). For a 6-digit number like 810000 that is 900 checks instead of 810000.

When \(n\) is a perfect square, one pair has two equal members, e.g. for 36 the pairs are (1, 36), (2, 18), (3, 12), (4, 9), (6, 6). Write 6 only once.

(ii) Not exactly as described. Listed pair by pair, the divisors are not in increasing order, e.g. divisors(18) becomes [1, 18, 2, 9, 3, 6]. Our gcd algorithm reported the rightmost element of the list of common divisors, which is the largest only because the lists were in increasing order.

Try gcd(12, 18) with pair-order lists: divisors(12) = [1, 12, 2, 6, 3, 4] and divisors(18) = [1, 18, 2, 9, 3, 6]. Checking each element of the first list against the second gives common divisors [1, 2, 6, 3]. The rightmost element is 3, but gcd(12, 18) = 6. The algorithm gives a wrong answer.

To repair it, change the last step to “report the largest element of the list of common divisors” (or sort the lists into increasing order first). With that change the pair method works, and is much faster.

Exercise Set 11.3

Q1

How would our original algorithm change if we computed the divisors of \(n\) by examining the numbers from 1 to \(n\) in reverse order, from \(n\) down to 1?

Answer

Scanning from \(n\) down to 1, each divisor found is added at the end of the list, so the list comes out in decreasing order. For example, divisors(18) becomes [18, 9, 6, 3, 2, 1].

The list of common divisors is built by going through the first list in order, so it is decreasing too. For gcd(375, 825) it becomes

\([75, 25, 15, 5, 3, 1]\)

If Step 5 is left unchanged (“report the rightmost element”), the algorithm reports 1, the smallest common divisor, which is wrong. The change needed is in Step 5:

Changed Step 5
  1. Report the leftmost element of common-divisors as gcd(m, n).

Now gcd(375, 825) = 75, correct. (Better still, since the first common divisor we meet is now the largest, we can stop as soon as we find it.)

Q2

What about the last algorithm described above? What happens when we look at common divisors starting from min(\(m\), \(n\)) and work backwards to 1?

Answer

Going downwards, the first common divisor we meet is the largest one, so it is the gcd. We no longer need most-recent-common-divisor to be updated again and again; we stop at the first hit:

Working backwards
  1. For each k in the sequence min(m, n), min(m, n) − 1, …, 2, 1:
    • if k divides both m and n, report k as gcd(m, n) and stop.

It always stops, at worst at \(k = 1\), because 1 divides every number.

m = 6, n = 12: min = 6. \(k = 6\) divides both 6 and 12, so gcd(6, 12) = 6 after 1 check (the forward scan in the book needed 5 checks, from 2 to 6).

m = 375, n = 825: min = 375. \(k = 375\) does not divide 825, nor does 374, 373, …; the first k that divides both is 75. The checks run from 375 down to 75:

\(375 - 75 + 1 = 301 \ \text{checks}\)

so gcd(375, 825) = 75.

Careful: if we kept the old rule (keep scanning to the end and update most-recent-common-divisor every time), the last update would be at \(k = 1\) and the answer would wrongly come out as 1. Working backwards only helps if we stop at the first common divisor.

In the worst case (gcd = 1) we still check every number from min(m, n) down to 1, so the effort still grows with the size of the numbers.

End-of-Chapter Exercises

Q1

Compute the following using the improved version of Euclid’s algorithm.

(i)gcd(375, 825)
(ii)gcd(51000, 81000)
(iii)gcd(1789287, 237656)
(iv)gcd(2587392, 157656)
Answer
Improved Euclid (Āryabhaṭa’s division) algorithm for gcd(m, n)
  1. If m < n, reverse the numbers and compute gcd(n, m).
  2. If n = 0, report the answer as m.
  3. Otherwise, reduce the problem to computing gcd(n, m mod n).

Here \(m \bmod n\) is the remainder when m is divided by n, so each reduction is one long division.

(i) gcd(375, 825)

Step 1: \(375 < 825\), so reverse and compute gcd(825, 375). Each row divides the first number by the second; the remainder becomes the new second number.

\(825 = 2 \times 375 + 75\)
\(375 = 5 \times 75 + 0\)
Problem gcd(m, n)m mod n
gcd(825, 375)75
gcd(375, 75)0

The remainder is now 0, so Step 2 gives gcd(375, 825) = 75, after 2 reductions. (The subtraction version in the book needed 7 reductions for the same pair.)

(ii) gcd(51000, 81000)

Step 1: \(51\,000 < 81\,000\), so reverse and compute gcd(81 000, 51 000). Each row divides the first number by the second; the remainder becomes the new second number.

\(81\,000 = 1 \times 51\,000 + 30\,000\)
\(51\,000 = 1 \times 30\,000 + 21\,000\)
\(30\,000 = 1 \times 21\,000 + 9000\)
\(21\,000 = 2 \times 9000 + 3000\)
\(9000 = 3 \times 3000 + 0\)
Problem gcd(m, n)m mod n
gcd(81 000, 51 000)30 000
gcd(51 000, 30 000)21 000
gcd(30 000, 21 000)9000
gcd(21 000, 9000)3000
gcd(9000, 3000)0

The remainder is now 0, so Step 2 gives gcd(51 000, 81 000) = 3000, after 5 reductions.

(iii) gcd(1789287, 237656)

Each row divides the first number by the second; the remainder becomes the new second number.

\(1\,789\,287 = 7 \times 237\,656 + 125\,695\)
\(237\,656 = 1 \times 125\,695 + 111\,961\)
\(125\,695 = 1 \times 111\,961 + 13\,734\)
\(111\,961 = 8 \times 13\,734 + 2089\)
\(13\,734 = 6 \times 2089 + 1200\)
\(2089 = 1 \times 1200 + 889\)
\(1200 = 1 \times 889 + 311\)
\(889 = 2 \times 311 + 267\)
\(311 = 1 \times 267 + 44\)
\(267 = 6 \times 44 + 3\)
\(44 = 14 \times 3 + 2\)
\(3 = 1 \times 2 + 1\)
\(2 = 2 \times 1 + 0\)
Problem gcd(m, n)m mod n
gcd(1 789 287, 237 656)125 695
gcd(237 656, 125 695)111 961
gcd(125 695, 111 961)13 734
gcd(111 961, 13 734)2089
gcd(13 734, 2089)1200
gcd(2089, 1200)889
gcd(1200, 889)311
gcd(889, 311)267
gcd(311, 267)44
gcd(267, 44)3
gcd(44, 3)2
gcd(3, 2)1
gcd(2, 1)0

The remainder is now 0, so Step 2 gives gcd(1 789 287, 237 656) = 1, after 13 reductions. The two numbers have no common divisor other than 1; they are co-prime.

(iv) gcd(2587392, 157656)

Each row divides the first number by the second; the remainder becomes the new second number.

\(2\,587\,392 = 16 \times 157\,656 + 64\,896\)
\(157\,656 = 2 \times 64\,896 + 27\,864\)
\(64\,896 = 2 \times 27\,864 + 9168\)
\(27\,864 = 3 \times 9168 + 360\)
\(9168 = 25 \times 360 + 168\)
\(360 = 2 \times 168 + 24\)
\(168 = 7 \times 24 + 0\)
Problem gcd(m, n)m mod n
gcd(2 587 392, 157 656)64 896
gcd(157 656, 64 896)27 864
gcd(64 896, 27 864)9168
gcd(27 864, 9168)360
gcd(9168, 360)168
gcd(360, 168)24
gcd(168, 24)0

The remainder is now 0, so Step 2 gives gcd(2 587 392, 157 656) = 24, after 7 reductions.

Compare with subtraction: Euclid’s subtraction version needs 7, 8, 51 and 57 reductions for parts (i) to (iv), against 2, 5, 13 and 7 divisions here. Each division does many subtractions in one step.
Q2

Assume that \(m \ge n\). Verify that \(d\) divides \(m\) and \(n\) if and only if \(d\) divides both \(n\) and \(m \bmod n\).

Answer

Divide m by n. If the quotient is q and the remainder is r, then \(r = m \bmod n\) and

\(m = q \times n + r\)
\(r = m - q \times n\)

(1) If d divides m and n, then d divides n and r. Write \(m = a \times d\) and \(n = b \times d\) for whole numbers a and b. Then

\(r = a \times d - q \times b \times d\)
\(= (a - q \times b) \times d\)

so d divides r. And d divides n is given.

(2) If d divides n and r, then d divides m and n. Write \(n = b \times d\) and \(r = c \times d\). Then

\(m = q \times b \times d + c \times d\)
\(= (q \times b + c) \times d\)

so d divides m. And d divides n is given.

Both directions hold, so the common divisors of m and n are exactly the common divisors of n and \(m \bmod n\). In particular the greatest of them are equal: \(\gcd(m, n) = \gcd(n,\ m \bmod n)\), which is why the improved Euclid algorithm is correct.

Example. m = 825, n = 375: \(825 = 2 \times 375 + 75\), so \(m \bmod n = 75\). The common divisors of 825 and 375 are 1, 3, 5, 15, 25, 75, and the common divisors of 375 and 75 are also 1, 3, 5, 15, 25, 75. A number such as 11 divides 825 but not 375, and it does not divide 75 either.

This is the same ‘tiling’ idea as Fig. 11.1, with m tiled by q copies of n and a leftover piece r.
Q3

Write an algorithm prime(\(n\)) to check if \(n\) is prime. (Hint: A prime number \(p\) has exactly two distinct factors, 1 and \(p\). Can you make use of divisors(\(n\)) to write out prime(\(n\))?)

Answer
Algorithm prime(n)
  1. Let divisors-of-n be the list obtained by computing divisors(n).
  2. If divisors-of-n has exactly 2 elements, report “n is prime”.
  3. Otherwise, report “n is not prime”.

This works because the list divisors(n) always contains 1 and n. It has exactly two elements precisely when there is nothing else, which is the definition of a prime.

ndivisors(n)Prime?
7[1, 7]yes (2 elements)
9[1, 3, 9]no (3 elements)
1[1]no (1 element)
2[1, 2]yes (2 elements)

Note that n = 1 is correctly reported as not prime: its list has only one element.

A faster version: check j = 2, 3, … only while \(j \times j \le n\) (Exercise Set 11.2, Q3). If none of them divides n and \(n \ge 2\), then n is prime.
Q4

* Write an algorithm primedivisors(\(n\)) to compute the list of divisors of \(n\) that are prime numbers. (Hint: Compute divisors(\(n\)) and then filter out the primes in this list.)

Answer
Algorithm primedivisors(n)
  1. Let divisors-of-n be the list obtained by computing divisors(n).
  2. Start with an empty list prime-divisors.
  3. For each number d in divisors-of-n:
    • if prime(d) reports “prime”, add d to prime-divisors.
  4. Report prime-divisors.

The algorithm uses prime(d) from Q3 as a basic step. Since divisors(n) is in increasing order, the list of prime divisors is too.

Trace for n = 60: divisors(60) = [1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60].

dprime(d)?prime-divisors
1no[]
2yes[2]
3yes[2, 3]
4no[2, 3]
5yes[2, 3, 5]
6no[2, 3, 5]
10no[2, 3, 5]
12no[2, 3, 5]
15no[2, 3, 5]
20no[2, 3, 5]
30no[2, 3, 5]
60no[2, 3, 5]

So primedivisors(60) = [2, 3, 5], and indeed \(60 = 2^2 \times 3 \times 5\).

Q5

* We can also find the gcd of two numbers by computing prime factorisation of both the numbers. Try to write an algorithm to compute the prime factorisation of a number.

(i)The prime factorisation of 180 is \(2^2 \times 3^2 \times 5^1\). How would you represent this?
(ii)How would you compare the prime factorisations of two numbers?
Answer

Algorithm. Use primedivisors(n) from Q4, then find how many times each prime goes into n by dividing repeatedly.

Algorithm factorise(n)
  1. Start with an empty list factors.
  2. For each prime p in primedivisors(n):
    • set count to 0;
    • while p divides n: replace n by n ÷ p and add 1 to count;
    • add the pair (p, count) to factors.
  3. Report factors.

Trace for n = 180: primedivisors(180) = [2, 3, 5].

pDivisionscount
2180 → 90 → 452
345 → 15 → 52
55 → 11

(i) Represent the factorisation as a list of pairs (prime, exponent), with the primes in increasing order:

\(180 \ \longrightarrow\ [(2, 2),\ (3, 2),\ (5, 1)]\)

Each pair (p, e) stands for \(p^e\), and the number is the product of all of them: \(2^2 \times 3^2 \times 5^1 = 180\). Primes that do not divide the number are simply left out.

(ii) To compare two factorisations, go through the primes. A prime that appears in both lists divides both numbers; the highest power of it dividing both is the smaller of the two exponents. So:

Algorithm gcd from two factorisations
  1. Start with answer = 1.
  2. For each pair (p, a) in the first list:
    • if the second list has a pair (p, b) with the same prime p, multiply answer by p, the smaller of a and b times.
  3. Report answer as gcd(m, n).

Example: gcd(180, 825). \(825 = 3 \times 5^2 \times 11\), i.e. [(3, 1), (5, 2), (11, 1)]. The common primes are 3 and 5:

\(\gcd(180, 825)\)
\(= 3^{\min(2,1)} \times 5^{\min(1,2)}\)
\(= 3^1 \times 5^1\)
\(= 15\)

Since both lists are in increasing order of primes, they can be compared in a single pass, like the merge in Exercise Set 11.2, Q1. Taking the larger exponent of every prime in either list gives the lcm instead:

\(\text{lcm}(180, 825)\)
\(= 2^2 \times 3^2 \times 5^2 \times 11\)
\(= (4 \times 25) \times (9 \times 11)\)
\(= 100 \times 99\)
\(= 9900\)
Factorising is slow for big numbers (it needs divisors(n)), which is why Euclid’s division algorithm is the better way to compute a gcd.