PYQ Vault

CDS Mathematics · Number System

Remainders by Congruence & Cyclicity

Finding the remainder of an astronomically large power by replacing the base with its own remainder, then exploiting the fact that powers cycle — with the special case of a base congruent to minus one, and Fermat's little theorem for a prime modulus.

Why this matters

Twenty-six PYQs, seven of them HARD — this is the densest HARD unit in the chapter after Factorisation, and CDS asks it every single year. The good news is that almost all of it is one of four moves. The base-congruent-to-minus-one trick alone accounts for six questions, and Fermat's little theorem for four.

Concept 1 of 6

Replacing a number by its remainder

Intuition

Remainders survive addition, subtraction and multiplication. So before doing anything with a huge number, replace it by its remainder on division by the modulus — the answer is unaffected and the arithmetic becomes trivial.

Definition

Write ab(modn)a \equiv b \pmod n to mean n(ab)n \mid (a-b), that is aa and bb leave the same remainder.

  • If aaa\equiv a' and bbb\equiv b' then a+ba+ba+b\equiv a'+b', ababa-b\equiv a'-b' and ababab\equiv a'b'.
  • In particular ak(a)ka^{k} \equiv (a')^{k}, which is what licenses reducing the base first.
  • Division is NOT allowed in general — you may not cancel a factor from both sides without checking it is coprime to the modulus.
  • The final answer must be brought into the range 00 to n1n-1.

Reduce the base first

ar(modn)    akrk(modn)a \equiv r \pmod n \;\Longrightarrow\; a^{k} \equiv r^{k} \pmod n

Worked example

What is the remainder when 43100043^{1000} is divided by 7?
Practice this conceptself-check · 4 quick reps

From the bank · past-year question

Example 1Number SystemMODERATE
What is the remainder after dividing the number 37100037^{1000} by 9 ?

[Q4 · CDS (II) 2021 — Elementary Mathematics · 2021]

A remainder must land in 0 to n minus 1

If your working produces 1-1 modulo 18, the remainder is 17, not 1-1. And a remainder on division by 9 can never be 9 — CDS puts exactly that value in the option list for the 37100037^{1000} question. Normalise before you answer.

Concept 2 of 6

When the base is one less than the modulus

Intuition

If a1a \equiv -1, then ana^{n} alternates: 1-1 for odd nn, +1+1 for even nn. Spotting that the base is one below the modulus is the single most productive observation in this unit, and it takes one glance.

Definition

If a1(modn)a \equiv -1 \pmod n — that is, a=n1a = n-1 or any number one less than a multiple of nn — then

ak(1)k={1k even1n1k odd.a^{k} \equiv (-1)^{k} = \begin{cases}1 & k \text{ even}\\ -1 \equiv n-1 & k \text{ odd.}\end{cases}

  • Look for it whenever the base is just under the modulus (17 and 18, 65 and 11 since 65=66165 = 66-1, pp and p+1p+1).
  • It pairs beautifully with a sum: if a1a\equiv-1 and b+1b\equiv+1, then ak+bk0a^{k}+b^{k}\equiv 0 for odd kk.
  • Also check a+1a \equiv +1, which is even simpler: every power is 1.

Alternating powers

a1(modn)    ak(1)k(modn)a\equiv -1 \pmod n \;\Longrightarrow\; a^{k}\equiv(-1)^{k}\pmod n

Worked example

What is the remainder when 2910129^{101} is divided by 30?
Practice this conceptself-check · 4 quick reps

From the bank · past-year question

Example 2Number SystemMODERATE
If 17202017^{2020} is divided by 18, then what is the remainder ?

[Q11 · CDS (II) 2020 — Elementary Mathematics · 2020]

Odd power of minus one is the modulus minus one, not minus one

65991(mod11)65^{99} \equiv -1 \pmod{11} means the remainder is 10. Writing 1-1 or 11 are the two wrong answers offered. Similarly 7847^{84} modulo 344 uses 3431343 \equiv -1 with an even exponent, giving 1 — the parity of the exponent is doing all the work, so read it carefully.

Concept 3 of 6

Finding the cycle of powers modulo n

Intuition

Powers of a fixed base repeat modulo nn. Compute them until you hit 1 (or repeat an earlier value) — the length of that loop is the cycle, and then only the exponent's remainder modulo the cycle length matters. This is the general tool when neither the minus-one trick nor Fermat applies directly.

Definition

Compute a1,a2,a3,a^{1}, a^{2}, a^{3},\ldots modulo nn until a value repeats. If at1a^{t}\equiv 1, the cycle length is tt and

akakmodt(modn),a^{k} \equiv a^{\,k \bmod t} \pmod n,
with the convention that a remainder of 0 means at1a^{t}\equiv 1.

  • Look for a small power that is ±1\pm 1; that shortcut usually appears within four or five steps (33=271mod283^3 = 27 \equiv -1 \bmod 28, 23=81mod72^3 = 8 \equiv 1 \bmod 7).
  • Finding at1a^{t}\equiv -1 is just as useful: the cycle is then 2t2t.

Cycle reduction

at1(modn)    akakmodt(modn)a^{t}\equiv 1 \pmod n \;\Longrightarrow\; a^{k}\equiv a^{\,k \bmod t} \pmod n

Worked example

What is the remainder when 2502^{50} is divided by 9?
Practice this conceptself-check · 4 quick reps

From the bank · past-year question

Example 3Number SystemMODERATE
What is the remainder when 210000002^{1000000} is divided by 7?

[Q2 · CDS (I) 2021 — Elementary Mathematics · 2021]

Reduce the exponent modulo the CYCLE, not modulo the divisor

For 2502^{50} modulo 9 the cycle is 6, so reduce 50 modulo 6 — not modulo 9. Mixing the two moduli is the standard error and produces a plausible wrong answer. The divisor sets the arithmetic; the cycle length sets the exponent reduction.

Concept 4 of 6

Fermat's little theorem

Intuition

For a prime modulus pp, any base not divisible by pp satisfies ap11a^{p-1}\equiv 1. So the cycle length always divides p1p-1, and you get the answer without hunting for the cycle at all. CDS names this theorem directly in one question and uses it in three more.

Definition

Fermat's little theorem. If pp is prime and pap \nmid a, then

ap11(modp).a^{p-1}\equiv 1 \pmod p.

  • Multiplying by aa gives the companion form apa(modp)a^{p}\equiv a \pmod p, valid for every aa including multiples of pp.
  • It requires the modulus to be prime: 331=263^{3}-1 = 26 is not a multiple of 4, so the statement fails at p=4p=4.
  • It explains why n5nn^{5}-n is always divisible by 5, and npnn^{p}-n by pp.

Fermat's little theorem

ap11(modp)(p prime, pa)a^{p-1}\equiv 1 \pmod p \quad (p \text{ prime},\ p \nmid a)

Worked example

What is the remainder when 3163^{16} is divided by 17?
Practice this conceptself-check · 4 quick reps

From the bank · past-year question

Example 4Number SystemHARD
What is the remainder when 21002^{100} is divided by 101 ?

[Q15 · CDS (II) 2016 — Elementary Mathematics · 2016]

The exponent p minus one gives 1; the exponent p gives the base back

2100mod101=12^{100} \bmod 101 = 1 but 2101mod101=22^{101} \bmod 101 = 2. CDS has set both, one year apart, and the option lists overlap. Check whether the exponent is p1p-1 or pp before answering, and remember the theorem needs the modulus prime — which is exactly what the 2017 statement question tests.

Concept 5 of 6

Pairing terms that cancel modulo n

Intuition

In a sum of several powers, look for pairs whose bases add to the modulus. Each such pair is ak+(a)ka^{k} + (-a)^{k}, which vanishes when kk is odd. A four-term sum can collapse to zero in one line.

Definition

If a+b0(modn)a+b \equiv 0 \pmod n — that is, bab \equiv -a — then for odd kk,

ak+bkak+(a)k=0(modn).a^{k}+b^{k} \equiv a^{k}+(-a)^{k} = 0 \pmod n.

  • Scan the bases for pairs summing to nn (or to a multiple of nn).
  • The exponent must be odd; for even kk the pair doubles instead of cancelling.
  • More generally, reduce every base and look for any structure — equal residues in a difference cancel too, which is why 2727152727^{27}-15^{27} is 0 modulo 6.

Cancelling pair

a+b0(modn), k odd    ak+bk0a+b\equiv 0 \pmod n,\ k \text{ odd} \;\Longrightarrow\; a^{k}+b^{k}\equiv 0

Worked example

What is the remainder when 117+12711^{7} + 12^{7} is divided by 23?
Practice this conceptself-check · 4 quick reps

From the bank · past-year question

Example 5Number SystemHARD
What is the remainder when 135+145+155+16513^5 + 14^5 + 15^5 + 16^5 is divided by 29 ?

[Q97 · CDS (II) 2016 — Elementary Mathematics · 2016]

Pair the bases before reducing them individually

In 135+145+155+16513^5+14^5+15^5+16^5 modulo 29 the structure is two pairs: 13+16=2913+16=29 and 14+15=2914+15=29. Reducing each base on its own gives four unhelpful residues and a long computation; noticing the pairing gives 0 immediately. Always add the outermost bases together first to check for this.

Concept 6 of 6

Remainders of sums, differences and products of given remainders

Intuition

If you know each number's remainder, you know the remainder of any sum, difference or product — just combine the remainders and reduce. The only care needed is with a difference, which can come out negative.

Definition

Given mr1m \equiv r_1 and nr2(modd)n \equiv r_2 \pmod d:

  • m+nr1+r2m+n \equiv r_1+r_2;
  • mnr1r2m-n \equiv r_1-r_2, and if that is negative add dd;
  • mnr1r2mn \equiv r_1 r_2;

then reduce into 00 to d1d-1. Note that m>nm>n does not imply r1>r2r_1>r_2 — the difference's remainder is determined by the residues, not by which number is bigger.

Combining remainders

mr1, nr2(modd)    m±nr1±r2,  mnr1r2m\equiv r_1,\ n\equiv r_2 \pmod d \;\Longrightarrow\; m\pm n\equiv r_1\pm r_2,\ \ mn\equiv r_1r_2

Worked example

Two numbers leave remainders 5 and 7 on division by 9. What remainders do their sum and their product leave?
Practice this conceptself-check · 4 quick reps

From the bank · past-year question

Example 6Number SystemMODERATE
There are two natural numbers m and n (m>n)(m > n). When m is divided by 12, it leaves a remainder 4. When n is divided by 12, it leaves a remainder 6. Which of the following statements is/are correct ? I. The remainder when (m+n)(m + n) is divided by 12 is 10. II. The remainder when (mn)(m - n) is divided by 12 is 10. Select the correct answer using the code given below :

[Q43 · CDS (I) 2025 — Elementary Mathematics · 2025]

m greater than n does not mean its remainder is greater

With m4m\equiv 4 and n6n\equiv 6 modulo 12 and m>nm>n, the difference is 46=2104-6=-2\equiv 10 — the same as the sum's remainder, which is why the 2025 question can truthfully say both are 10. Students who assume r1>r2r_1>r_2 because m>nm>n compute 64=26-4=2 and get it wrong.

Summary — formulas & gotchas at a glance

A revision cheat-sheet for the formulas and gotchas above. Click any concept name to jump back to its full explanation.

Formulas (6)

  • Replacing a number by its remainder

    Reduce the base first

    ar(modn)    akrk(modn)a \equiv r \pmod n \;\Longrightarrow\; a^{k} \equiv r^{k} \pmod n
  • When the base is one less than the modulus

    Alternating powers

    a1(modn)    ak(1)k(modn)a\equiv -1 \pmod n \;\Longrightarrow\; a^{k}\equiv(-1)^{k}\pmod n
  • Finding the cycle of powers modulo n

    Cycle reduction

    at1(modn)    akakmodt(modn)a^{t}\equiv 1 \pmod n \;\Longrightarrow\; a^{k}\equiv a^{\,k \bmod t} \pmod n
  • Fermat's little theorem

    Fermat's little theorem

    ap11(modp)(p prime, pa)a^{p-1}\equiv 1 \pmod p \quad (p \text{ prime},\ p \nmid a)
  • Pairing terms that cancel modulo n

    Cancelling pair

    a+b0(modn), k odd    ak+bk0a+b\equiv 0 \pmod n,\ k \text{ odd} \;\Longrightarrow\; a^{k}+b^{k}\equiv 0
  • Remainders of sums, differences and products of given remainders

    Combining remainders

    mr1, nr2(modd)    m±nr1±r2,  mnr1r2m\equiv r_1,\ n\equiv r_2 \pmod d \;\Longrightarrow\; m\pm n\equiv r_1\pm r_2,\ \ mn\equiv r_1r_2

Watch out for (6)

Drill every past-year question on this subtopic

26 questions from the bank — paginated, with cart and Word-export support.

Related notes