Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|cite|improve this question
Are 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
up vote 3 down vote accepted

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.)

share|cite|improve this answer

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.

share|cite|improve this answer
this is absolutely right answer – iostream007 May 10 '13 at 6:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.