I have to get all combinations of a six digit number where each digit is unique. Its clear that this combination will not have a 0 at the start as it will not be a valid six digit number. Help me on how to attack this problem.
-
2Are you assuming that the first digit can't be 0 or is it explicitly stated? Because in something like a PIN, 0 is a valid leading digit. – Thomas Owens Aug 31 '10 at 12:01
-
just count all combinations where each digit is unique, and subtract all combinations starting with 0 and having unique digits in (1,2,...9) :-) – mau Aug 31 '10 at 12:17
2 Answers
First, if you're talking about a six-digit number, the order of the digits matters, so it's generally not referred to as a combination.
Consider how many possibilities there are for the first digit. As you said, it cannot be zero, or you wouldn't have a six-digit number. Once there is a first digit, how many possibilities are there for the second digit? Then for the third? And so on.
The total number of six-digit numbers is the product of the various numbers of possibilities for each digit.
(As the question feels like homework to me, this is more of a hint/outline than a complete answer. If it actually is homework, please add the homework tag. If it's not homework, or if this doesn't get you to an answer, please comment with more information.)
- 36,557
This seems simple : The digits will be from the set {0,1,2,3,4,5,6,7,8,9}
Number of possibility for first digit (Most significant digit) = 9 (since we can't use 0) Number of possibility for second digit = 9 Number of possibility for third digit = 8 ... Number of possibility for sixth digit (Least significant digit) = 5
Hence total possibility = 9*9*8*7*6*5.
- 22,431