Question
Question: number of ways we can form a number of 4 digits that have atmost 2 different digits...
number of ways we can form a number of 4 digits that have atmost 2 different digits
576
Solution
To find the number of 4-digit numbers that have at most 2 different digits, we consider two cases:
Case 1: The number has exactly 1 different digit.
This means all four digits are the same. Let the number be AAAA. Since it is a 4-digit number, the first digit A cannot be 0. So, A can be any digit from 1 to 9. Possible numbers are 1111, 2222, ..., 9999. Number of ways = 9.
Case 2: The number has exactly 2 different digits.
Let the two distinct digits be d1 and d2. The 4-digit number must contain both d1 and d2. We need to consider two subcases based on whether 0 is one of the digits.
Subcase 2.1: One of the distinct digits is 0.
Let the two distinct digits be x and 0, where x∈{1,2,...,9}. There are 9 choices for x. The 4-digit number must contain both x and 0. Since the number is a 4-digit number, its first digit cannot be 0. Therefore, the first digit must be x. So the number is of the form xBCD. The remaining three digits (B,C,D) can be either x or 0. There are 23=8 possible arrangements for BCD. However, we must ensure that 0 is present among B,C,D. The only arrangement that does not contain 0 is xxx. So, we exclude the case xBCD=xxxx (which would fall under Case 1). Number of valid arrangements for BCD is 23−1=7. For each of the 9 choices for x, there are 7 ways to form the number. Number of ways = 9×7=63.
Subcase 2.2: Neither of the distinct digits is 0.
Let the two distinct digits be x and y, where x,y∈{1,2,...,9} and x=y. The number of ways to choose two distinct digits from {1,2,...,9} is (29). (29)=29×8=36. For each chosen pair {x,y}, we need to form a 4-digit number using only x and y, such that both x and y are present. Since neither x nor y is 0, the first digit can be either x or y. Each of the four positions in the number can be filled with either x or y. So there are 24=16 total arrangements. From these 16 arrangements, we must exclude the cases where only x is used (xxxx) and where only y is used (yyyy). These cases would fall under Case 1. So, the number of valid arrangements for each pair {x,y} is 24−2=14. Number of ways = (29)×14=36×14=504.
Total number of ways:
Sum of ways from Case 1, Subcase 2.1, and Subcase 2.2.
Total = 9+63+504=576.