# How many 4 digit numbers are there which contains not more than 2 different digits? [duplicate]

How many 4 digit numbers are there which contains not more than 2 different digits?

My attempt

total no. of digits - the digits which have all different digits.

i.e (9.10.10.10)-(9.9.8.7)=4464

But the answer is 576..What am i missing..Is there any other way to solve this.?

• A few things: order matters, and having three or four digits equal also means (at least) two digits are equal. – M Turgeon Aug 28 '13 at 15:20
• What about $1123$? It doesn't have all different digits, but it does contain more than two different digits. – Michael Albanese Aug 28 '13 at 15:20
• you could consider numbers of the form $xxyy$ and all permutations where $x$ and $y$ are different digits, i.e. $x,y\in\{0,\dots,9\}$, $x\neq y$. Now you have to be careful about the number of permutation if one of the numbers is zero. But that can be a way to calculate what you want. And of course you add $1111,2222,\dots$. – Dima McGreen Aug 28 '13 at 15:23

The first (non-zero) digit of the number $F$ (thousands digit) can be any one of nine. The second digit $S$ which is used if there are two digits can be any one of the nine digits different from the first.

Now consider the Hundreds Tens and Units digits in the case that there are two digits used in the number. We have two possibilities $F$ or $S$ to fill each place - but we exclude $FFF$ as not involving two digits, so there are $2^3-1=7$ possible patterns with exactly two different digits and $9\times 9$ ways of choosing the pair of digits in the first place.

Then there are nine possibilities with just one digit.

So the total you want is $9\times 9 \times 7 + 9=576$

• Nice solution Mark Bennet. – juantheron Nov 8 '13 at 13:13

There are $9 \times 9$ 4-digit numbers of the type $aabb$. Permutations of $aabb$ are:

$aabb, bbaa, abab, baba, abba, baab$, but note that the first and the second, the third and the fourth and the fifth and the sixth are completly the same, so there are 3 different permutations.

Which means that there are 243 4-digit numbers of the type $aabb$ and its permutation.

There are $9 \times 9$ 4-digit numbers of the type $aaab$. Permutations are:

$aaab, aaba, abaa, baaa$, so there are 4 distinct permutations, which means there are 324 4-digit numbers of the type $aaab$ and its permutation.

And finally we have 9 4-digit numbers of the typee $aaaa$.

If we add all up the number we'll reach the number of 576 4-digit number that satisfy the condition.

In your aproach you missed the number that have 3 different digits.

There are $9 \times 9 \times 8 \times 7$ 4-digit numbers that have 4 different digits.

There are $9 \times 9 \times 8$ 4-digit number that have 3 different digits. But this 3 different digits can be place on 6 different ways: $aabc, abac, abca, baac, baca, bcaa$, so we multiply the number of combintion by 6.

We know that there are 9000 4-digit numbers so we have:

$$9000 - 9 \times 9 \times 8 \times 7 - 9 \times 9 \times 8 \times 6 = 9000 - 4536 - 3888 = 576\text{ numbers that satisfy the condition }$$

• 4-digit number that have 3 different digits. aabc,abac,abca,baac,baca,bcaa...but there are more caab,caba.cbba – maths lover Aug 28 '13 at 16:05
• baac is the same as caab, beacuse we can chose the freely. For example 1002 is a number of that type. Using first notation: $b=1, a=0, c=2$ and in the second $c=1,a=0,b=2$ – Stefan4024 Aug 28 '13 at 16:52

Let n1,n2,n3 & n4 be four possible digits of solution respectively from left to right.

ie n1*1000 + n2*100 + n3*10 + n4 is the 4 digit number.

Suppose n1 is 1. then n2,n3 & n4 can have either 1 or any one of remaining 9 numbers.

case 1: if one of those three digits is 1, remaining two digits has the other number, then possibilities is 9*(3C1)=9*3 = 27.

here 3C1 is the ways of choosing one digit for 1 among n2,n3,n4, which is multiplied with 9,which is the n.o of possible numbers {0,2,3,4,5,6,7,8,9} at the remaining 2 digits

eg: 11xx,1x1x,1xx1

Case 2: if two places has 1, remaining place will have the other digit, then possibilities is 9*(3C2)= 27.selecting 2 digits out of 3 for 1.

eg: 111x,11x1,1x11

Case 3: if 3 places has 1, then possibilities = 1, ie 1111 is the number. Case 4: if no places has 1, then possibilities = 9, ie 1xxx , where x can be any one from {0,2,3,4,5,6,7,8,9}

Adding all these possibilities = 64.

now for n1 =1, 64 possibilities, so for n1 = 1 to 9, n.o of possibilities = 9*64 = 576.

First, your text confuses "digits" with "numbers". It should be total number of numbers=

Second, if you deduct numbers with four different digits from all numbers, you still include those with three different digits.

Your approach is fine if you also subtract the ones with three different digits, one of which is duplicated.