Find the number of three-digit numbers (integers from 100 to 999) that contain no two consecutive equal digits.

Find the number of three-digit numbers (integers from 100 to 999) that contain no two consecutive equal digits.

My thoughts were, there a 1-9 choices for position one; so 9 choices. For the second position there are 0-9 choices but it cannot be the same as the first, so there are 9 choices, and for the last position there are 0-9 choices, but it can't be the same as the second so there are again 9 choices. So my answer is $9^3 = 729$.

I have checked on this website and found a similar problem, but their reasoning and answer did not match with my answer. Please tell me what I am doing wrong and what the correct answer is.

• Your reasoning seems correct. – Aniruddha Deshmukh Jun 25 '17 at 6:04

You reasoning is correct: there are 9 options for every digit, resulting in $9^3 = 729$ valid three-digit numbers. You can verify this result with the following Python script:

i = 0
for a in range(1, 10):
for b in range(0, 10):
for c in range(0, 10):
if a != b != c:
i += 1
print(i)


In general, the number of $n$-digit numbers with no two consecutive equal digits equals $9^n$.