[Math] How many 4-digit numbers have at least two consecutive digits that are the same

combinatoricsprobability

How many $4$-digit numbers have at least two consecutive digits that are the same?

Solve this problem in two ways, and explain both solutions:

(a) Use PIE.

(b) Use complementary counting.

Best Answer

I only know how to do this by complementary counting:

(All 4-digit number) - (All 4-digit numbers with no consecutive digits that are the same)

All 4-digit number:

This is simply 1000 to 9999 inclusive, for a total of 9000 distinct numbers.

All 4-digit numbers with no consecutive digits that are the same:

We can count this through constructive counting. For the thousand digit, we have 9 possibilities (1 to 9, 0 is not an option). For the hundred digit, we have 10 possibilities (0 to 9). However, Since consecutive digits must not be the same, we have now only 9 possibilities (discarding whatever number the thousand digit is). The same goes for the tens and unit digit.

For a total of $9^4 = 6561$ possibilities.

Subtract the two, there are $9000 - 6561 = 2439$ of such numbers.