# How many $5$-digit numbers can be formed from digits $0 ,1,....9$ such that no $2$ same digits are sit next to each other

How many $5$-digit numbers can be formed from digits $0 ,1,....9$ such that no $2$ same digits are sit next to each other?

I tried to solve the problem but complement as following

There are
$$9 \cdot 10 \cdot 10 \cdot 10 \cdot 10$$
$5$-digit numbers.

Now I find ways to form $5$-digit number with $2$ same digits. $$9 \cdot 5C2 \cdot 9C3 \cdot 4!$$ "First choose $2$ places out of $5$, then fill them by $9$ ways and fill the other $3$ places by $9C3$ and finally permute them all."

Then the answer $= 9 \cdot 10 \cdot 10 \cdot 10 \cdot 10 - 9 \cdot 5C2 \cdot 9C3 \cdot 4!$

Is my work true? Is there a simpler way ?

The first digit cannot be a $0$, so you've got $9$ digits to choose from ($1$ to $9$). The second digit cannot be the same as the first, so again you've got $9$ digits to choose from (all but the one you chose for the first digit). The third digit cannot be the same as the second, so again there are $9$ choices. And so on. So you've got $9^5$ numbers fulfilling the condition.
• @UddeshyaSingh: No. After you've chosen the digit $9$ as first digit, I explicitly excluded that choice for the second digit (that's why you only have $9$ digits to choose from as second digit, not $10$). Commented Apr 14, 2017 at 12:10