How many 4-digit numbers can be formed using the digits 0, 1, 2, 3, 4 and 5 without repetition?
300. The first digit cannot be 0, so it has 5 choices. The remaining three places use the other 5 digits: 5 x 4 x 3. Total = 5 x 5 x 4 x 3 = 300.
Explain it simply
Fill the places one at a time and multiply the choices. Handle the place with a restriction first. A 4-digit number cannot begin with 0, so the thousands place gets first treatment. After that, 0 is allowed again, and each place just has one fewer digit available.
Example
Question: 4-digit numbers from 0 to 5, no repetition.
- Thousands place: 1 to 5, so 5 choices.
- Hundreds place: any of the remaining 5 digits (0 is now allowed).
- Tens: 4 choices. Units: 3 choices.
- Total = 5 x 5 x 4 x 3 = 300.
Check: all 4-digit strings without repetition = 6 x 5 x 4 x 3 = 360. Those starting with 0 = 5 x 4 x 3 = 60. 360 - 60 = 300.
let count = 0;
for (let n = 1000; n <= 9999; n++) {
const s = String(n);
if ([...s].every(d => d <= "5") && new Set(s).size === 4) count++;
}
console.log(count); // Output: 300What to say in the interview
"The first digit can't be zero, so 5 choices, and then 5, 4, 3 for the rest. That's 300, and 360 minus the 60 strings starting with zero agrees."
Common mistakes
- Giving 6 choices to the first place and answering 360.
- Giving only 4 choices to the second place, forgetting that 0 becomes available there.