I want to compute the number of numbers of length $N$ , such that count of digit 5 is 2 and count of digit 7 is 3. The rest of the places can be filled by any digits i.e. repetition is allowed.

Can I directly calculate it or do I have to make cases?

For example, below are some valid numbers of length $8$, where count of $5$ is $2$ and count of $7$ is $3$.

  • $\begingroup$ What do you mean by 'count of digit 5 is 2' ? is it that 5th digit is 2 ? $\endgroup$ – Maximus Apr 17 '17 at 9:59

You can almost calculate it without any cases, but there is a slight extra complication from the fact that the first digit can't be $0$.

If you just wanted to know how many strings of $N$ digits with exactly two $5$s and three $7$s, then you can first choose two places from $N$ for the $5$s, then three places (from the remaining $N-2$) for the $7$s. Then you have $N-5$ places to fill, and each one can be any of the other $8$ digits. So that gives $\binom N2\binom{N-2}38^{N-5}$ ways.

Unfortunately this includes things like $05787735$, which you don't want. So you need to subtract off the number of strings which start with a $0$, and have two $5$s and three $7$s. You should be able to use the same method to calculate how many strings of this form there are.

  • $\begingroup$ How do you account for repetitions here. The 8^(N-5) factor adds repetitions like 5577788 - this number will be added twice as 8 is repeated. So can any other number. $\endgroup$ – Maximus Apr 17 '17 at 10:20
  • $\begingroup$ The question says repetitions are allowed so this is the right factor. $\endgroup$ – Especially Lime Apr 17 '17 at 10:23
  • $\begingroup$ @Maximus: There are repetitions, but this method does not over count. $\endgroup$ – Akay Apr 17 '17 at 17:52

Hint -

You have to take cases where 5 repeated at least twice and 7 repeated at least thrice.

Alternate way is find the number of ways number with length N can be arranged and then subtract cases with at most 5 repeating only once and 7 repeating at most twice.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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