---
title: "Count of Surjective Functions with Image Restriction"
organization: "NityaDhi Digital Mathematics Lab (Asa Edtech Private Limited)"
url: "https://www.nityadhi.com/problems/hard-c11-w1-19-onto-functions-restricted-element"
board: "JEE Foundation"
grade: "Class 11"
published_at: "2026-11-30T12:45:00+05:30"
---

# Count of Surjective Functions with Image Restriction

Let $A = \{1, 2, 3, 4, 5, 6\}$ and $B = \{a, b, c, d\}$. Find the total number of **onto (surjective)** functions $f: A \to B$ such that $f(1) \neq a$.

## Textbook Solution

First, find the total number of onto functions from a $6$-element set $A$ onto a $4$-element set $B$ using Inclusion-Exclusion:
$$N_{\text{onto}} = \sum_{k=0}^{4} (-1)^k \binom{4}{k} (4 - k)^6 = 4^6 - \binom{4}{1} 3^6 + \binom{4}{2} 2^6 - \binom{4}{3} 1^6$$
Compute each term:
- $4^6 = 4096$
- $4 \times 3^6 = 4 \times 729 = 2916$
- $6 \times 2^6 = 6 \times 64 = 384$
- $4 \times 1^6 = 4$
Thus:
$$N_{\text{onto}} = 4096 - 2916 + 384 - 4 = 1560$$
Now impose the condition $f(1) \neq a$. Partition the valid onto functions according to $f(1) \in \{b, c, d\}$ ($3$ symmetric choices):
- **Case 1:** $f(1)$ is the unique element mapping to its chosen value (say $b$). Then $\{2, 3, 4, 5, 6\}$ must map onto $\{a, c, d\}$ (a $5$-element set onto a $3$-element set):
  $$\text{Count} = 3 \times \left(3^5 - 3\cdot 2^5 + 3\cdot 1^5\right) = 3 \times (243 - 96 + 3) = 3 \times 150 = 450$$
- **Case 2:** At least one element from $\{2, 3, 4, 5, 6\}$ also maps to $f(1)$, so $\{2, 3, 4, 5, 6\}$ maps onto all $4$ elements of $B$:
  $$\text{Count} = 3 \times \left(4^5 - 4\cdot 3^5 + 6\cdot 2^5 - 4\cdot 1^5\right) = 3 \times (1024 - 972 + 192 - 4) = 3 \times 240 = 720$$

Adding both cases gives $450 + 720 = 1170$.

## Vedic Shortcut

**NityaDhi Codomain-Symmetry Shortcut:** Because the surjectivity condition treats all four elements $\{a, b, c, d\}$ identically, among all $1560$ onto functions, the value $f(1)$ is equally distributed among $a, b, c,$ and $d$! Hence $f(1) \neq a$ holds for exactly $\frac{3}{4}$ of all onto functions:
$$\frac{3}{4} \times 1560 = 1170$$
And $N_{\text{onto}} = 4! \cdot S(6,4) = 24 \times (20 + 45) = 1560$ via partition sizes $(3,1,1,1)$ and $(2,2,1,1)$!

## Common Mistakes

1. **Computing $(3)(4^5 - 4\cdot 3^5 + \dots)$ only (Case 2):** Students often assume $\{2,3,4,5,6\}$ must still map onto all $4$ elements of $B$, forgetting Case 1 where $1$ is the sole preimage of $f(1)$.
2. **Multiplying $4^6$ by $\frac{3}{4}$ before enforcing surjectivity:** Subtracting functions with $f(1)=a$ from $3\cdot 4^5$ counts non-onto functions as well.