PYQ Vault

JEE Mains Maths · Permutations and Combinations

Divisibility, Divisors and Factorials

Counting with number theory: the power of a prime in n!, divisors of a given form, how many numbers in a range are multiples of one number but not another, and pairs chosen by their remainders.

Why this matters

Twenty PYQs, fifteen of them numerical answer. Five find the power of a prime in a factorial, ten count multiples or gcd conditions by inclusion–exclusion, and five sort numbers by remainder before pairing them. Three ideas cover the page.

Concept 1 of 3: Powers of a prime in n!, and counting divisors

The power of a prime pp in n!n! is ⌊np⌋+⌊np2⌋+⋯\left\lfloor\frac np\right\rfloor+\left\lfloor\frac n{p^2}\right\rfloor+\cdots: each multiple of pp gives one factor, each multiple of p2p^2 one more, and so on. For a composite base like 40=23⋅540=2^3\cdot5, the answer is the smallest of the separate limits. A number paqb⋯p^aq^b\cdots has (a+1)(b+1)⋯(a+1)(b+1)\cdots divisors; a condition on the divisor (odd, of the form 4n+14n+1) restricts each exponent.

Definition

  • Legendre: vp(n!)=∑k≥1⌊npk⌋v_p(n!)=\sum_{k\ge1}\left\lfloor\frac{n}{p^k}\right\rfloor.
  • Largest mm with am∣n!a^m\mid n!: min⁡p⌊vp(n!)vp(a)⌋\min_p\left\lfloor\frac{v_p(n!)}{v_p(a)}\right\rfloor.
  • Divisors of paqbp^aq^b: (a+1)(b+1)(a+1)(b+1).
  • Odd divisors: set the exponent of 2 to 0.

Legendre's formula

vp(n!)=⌊np⌋+⌊np2⌋+⌊np3⌋+⋯v_p(n!)=\left\lfloor\frac np\right\rfloor+\left\lfloor\frac n{p^2}\right\rfloor+\left\lfloor\frac n{p^3}\right\rfloor+\cdots

Worked example

Find the largest nn with 5n∣100!5^n\mid 100!.
Practice this conceptself-check · 4 quick reps

The same idea in a real exam question:

JEE Mains · 2025 · 2 Apr 2025 · Q51Moderate

Example 1 · Permutations and Combinations · Divisibility, Divisors and Factorials

The largest n∈Nn \in N such that 3n3^{n} divides 50 ! is:

The scarcer prime decides

For 40n∣n!40^n\mid n! you need both 23n2^{3n} and 5n5^n. Compute each limit and take the smaller; the prime that appears less often usually wins.

Concept 2 of 3: Counting multiples in a range

The multiples of dd up to NN number ⌊Nd⌋\left\lfloor\frac Nd\right\rfloor; in a range, subtract the count below it. 'By aa or bb' is ∣A∣+∣B∣−∣A∩B∣|A|+|B|-|A\cap B|, where the overlap counts multiples of lcm⁡(a,b)\operatorname{lcm}(a,b). A gcd condition such as gcd⁡(n,54)=2\gcd(n,54)=2 becomes 'even, and not divisible by 3'.

Definition

  • Multiples of dd in [a,b][a,b]: ⌊bd⌋−⌊a−1d⌋\left\lfloor\frac bd\right\rfloor-\left\lfloor\frac{a-1}d\right\rfloor.
  • ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A\cup B|=|A|+|B|-|A\cap B|; overlap uses the lcm.
  • gcd⁡(n,m)=g\gcd(n,m)=g: g∣ng\mid n and gcd⁡(ng,mg)=1\gcd\left(\frac ng,\frac mg\right)=1.
  • Coprime to 24 means not divisible by 2 or 3.

Inclusion–exclusion

∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A\cup B|=|A|+|B|-|A\cap B|

Worked example

How many numbers from 1 to 100 are divisible by 4 or 6?
Practice this conceptself-check · 4 quick reps

The same idea in a real exam question:

JEE Mains · 2023 · 29 January 2023 · Q163Moderate

Example 2 · Permutations and Combinations · Divisibility, Divisors and Factorials

The number of 3 digit numbers, that are divisible by either 3 or 4 but not divisible by 48 , is

Use the lcm, not the product

Numbers divisible by both 4 and 6 are multiples of 12, not of 24. Always take the lcm for the overlap.

Concept 3 of 3: Pairing numbers by their remainders

To count pairs whose sum is divisible by mm, sort the numbers by remainder mod mm: a pair works when the remainders add to 00 or mm. Multiply the class sizes for each matching pair of classes. Powers work the same way: 6m≡1(mod5)6^m\equiv1\pmod5 for every mm, so only the other term decides.

Definition

  • x+y≡0(modm)x+y\equiv0\pmod m: remainders rr and m−rm-r.
  • Same class r=0r=0 (or r=m2r=\frac m2): choose two from one class.
  • Ordered pairs: count (r,s)(r,s) and (s,r)(s,r) separately.
  • Cycles of powers mod mm decide divisibility of sums of powers.

Matching classes

#{x+y≡0}=∑r+s≡0∣Cr∣ ∣Cs∣\#\{x+y\equiv0\}=\sum_{r+s\equiv0}|C_r|\,|C_s|

Worked example

How many unordered pairs of distinct numbers from 1 to 10 have a sum divisible by 3?
Practice this conceptself-check · 4 quick reps

The same idea in a real exam question:

JEE Mains · 2023 · 25 Jan 2023 · Q87Moderate

Example 3 · Permutations and Combinations · Divisibility, Divisors and Factorials

Let xx and yy be distinct integers where 1≤x≤251 \leq x \leq 25 and 1≤y≤251 \leq y \leq 25. Then, the number of ways of choosing xx and yy such that x+yx+y is divisible by 5, is

Ordered or unordered

'Ways of choosing xx and yy' with named variables counts ordered pairs. Decide before multiplying, and for pairs inside one class use k(k−1)k(k-1) ordered or (k2)\binom k2 unordered.

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 (3)

  • Powers of a prime in n!, and counting divisors

    Legendre's formula

    vp(n!)=⌊np⌋+⌊np2⌋+⌊np3⌋+⋯v_p(n!)=\left\lfloor\frac np\right\rfloor+\left\lfloor\frac n{p^2}\right\rfloor+\left\lfloor\frac n{p^3}\right\rfloor+\cdots
  • Counting multiples in a range

    Inclusion–exclusion

    ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A\cup B|=|A|+|B|-|A\cap B|
  • Pairing numbers by their remainders

    Matching classes

    #{x+y≡0}=∑r+s≡0∣Cr∣ ∣Cs∣\#\{x+y\equiv0\}=\sum_{r+s\equiv0}|C_r|\,|C_s|

Watch out for (3)

Test yourself on Permutations and Combinations

20 past JEE Mains questions from this chapter, timed at 48 minutes and marked the way the exam marks it. You see your score and every answer the moment you finish. Free to start.