As the title says, how many n-digit numbers can be formed using the first 5 natural numbers which must contain the digits 2 and 4 essentially?

I think this can be done using some sort of principle of inclusions, but I am not able to do it in that way...

Can someone guide me in the right direction?


closed as off-topic by JMoravitz, Arnaud D., Shailesh, Marcus M, Aqua Nov 8 '17 at 17:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – JMoravitz, Shailesh, Marcus M, Aqua
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    $\begingroup$ Do you consider $0$ a natural number? Yes the problem will utilize the principle of inclusion-exclusion. Can you count the number of such $n$-digit numbers with no twos? Can you count the number of such $n$-digit numbers with no fours? Can you count the number of such $n$-digit numbers with neither twos nor fours? Can you count the number of such $n$-digit numbers where you don't care about whether there are any of either? $\endgroup$ – JMoravitz Nov 8 '17 at 5:39
  • $\begingroup$ @JMoravitz 0 is not considered as a natural number in this case, as usual, and thanks for the insight... That helped me to take the right cases... $\endgroup$ – AbhigyanC Nov 8 '17 at 16:09
  • $\begingroup$ "is not considered as a natural number, as usual" I find it is much more common to consider zero a natural than otherwise, but both are used. it feels like maybe 70-30 in favor of zero being considered a natural $\endgroup$ – JMoravitz Nov 8 '17 at 16:10
  • $\begingroup$ @JMoravitz Oh... I was unaware that 0 is even treated as a natural number in any place, having grown up hearing that there's natural numbers ($\{1,2,3,4...\}$) and whole numbers ($\{0,1,2,3,4...\}$)... I'm from India, here we have always learnt that 0 is a natural number; hence I said "as usual" :) $\endgroup$ – AbhigyanC Nov 8 '17 at 17:04

Let us consider multiple cases to solve this:

Total number of numbers present of n-digit made up of 1st 5 natural no.s is $ S=5^n$

Case 0: This case considers with atleast one 2 present and no 4's present

$ \implies S_0= \ ^nC_13^{n-1} +\ ^nC_23^{n-2} +\ ^nC_33^{n-3}+ \ ...+ \ ^nC_n $

$ \implies S_0=4^n-1$

Case 1: This case considers with atleast one 4 present and no 2's present

$ \implies S_1= \ ^nC_13^{n-1} +\ ^nC_23^{n-2} +\ ^nC_33^{n-3}+ \ ...+ \ ^nC_n $

$ \implies S_1=4^n-1$

Case 2: No 2's or 4's are present

$ \implies S_2=3^n $

So, total no. of such values are


$\implies s=5^n-2(4^n-1)-3^n$


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