Carlos uses a -digit passcode to unlock his computer. In his passcode, exactly one digit is even, exactly one (possibly different) digit is prime, and no digit is . How many -digit passcodes satisfy these conditions?
- A)
- B)
- C)
- D)
- E)
Answer
D
Key insight
Sort digits 1 to 9 into groups: 2 is even and prime, 4, 6, 8 only even, 3, 5, 7 only prime, 1 and 9 neither. Then count two cases.
Solution
Two rules overlap here (one even digit, one prime digit), so first sort the digits to by which rules they touch.
- Sort the digits.
| Group | Digits | How many |
|---|---|---|
| even and prime | ||
| even, not prime | ||
| prime, not even | ||
| neither |
Remember that is not prime, and is not prime.
- Split into two cases. The even digit and the prime digit might be the same digit, or two different digits.
3. Case 1: one digit is both even and prime. That digit must be . The other three digits can be neither even nor prime, so each is or .
- Where does the go? choices.
- Each of the other three spots: choices.
4. Case 2: two different digits. One spot has an even digit that is not prime, and another spot has a prime digit that is not even. A cannot appear here, since it would add a second even digit and a second prime digit. The last two spots are or .
- Spot for the even digit: choices.
- Spot for the prime digit: choices (any other spot).
- Which even digit (, or ): choices.
- Which prime digit (, or ): choices.
- The two remaining spots: choices.
5. Add the cases. A passcode either has a (Case 1) or does not (Case 2), so no passcode is counted twice:
The answer is .
Why this works
When two conditions overlap, a small table of which items satisfy which condition shows every situation at once. Here it makes clear that is special and that only and can fill the leftover spots. After that, each case is just "choose the spots, then choose the digits" and multiply.
The trap
Forgetting that 2 is both even and prime, so a single 2 can do both jobs. Counting only codes with one even digit and a different prime digit gives 432, choice (C).
Concise solution
The available digits are through . Sort them by the two properties:
- even and prime: (one digit),
- even but not prime: (three digits),
- prime but not even: (three digits),
- neither: (two digits).
Exactly one position holds an even digit and exactly one position holds a prime digit. Those two positions may or may not coincide.
One digit does both jobs. That digit must be , and the other three digits must be neither even nor prime, so each is or . Choose the position of the in ways and fill the rest in ways:
Two different positions. One position holds an even non-prime digit ( choices) and a different position holds a prime non-even digit ( choices); the other two positions are or . Note that cannot appear here, since it would make the even count and the prime count both too large. Choosing the two special positions in order gives ways:
The two cases are disjoint, so the total is
The answer is .
Review in the AoPS books
- Introduction to Counting & Probability, Chapter 1: Counting Is Arithmetic
- Introduction to Counting & Probability, Chapter 2: Basic Counting Techniques (§2.5)
- Introduction to Counting & Probability, Chapter 3: Correcting for Overcounting (§3.2, §3.4)
- Prealgebra, Chapter 14: Counting (§14.3)
Techniques
Split into exhaustive cases and handle each · Set up the equation/formula and compute; no special trick needed