# Question on combinatorics and the inclusion-exclusion principle

Find the number of n digit-numbers formed using the first 5 natural numbers, that contain the digits '2' and '4', essentially.

I tried attempting this with the inclusion- exclusion principle but got stuck with the first 5 natural numbers condition. I made 2 sets, one with natural numbers where 2 is there and another with numbers with 5 is there and tried to find their intersection, but got stuck while subtracting from the total set, ie, the set of natural n digit numbers that are made from the digits 1 to 5 (wo any restrictions) hence i have a doubt in how to find the total number of elements in the set of n digit numbers that are made from the first 5 natural numbers.

The total number of $$n$$-digit numbers formed from $$12345$$ is $$5^n$$. The count of those numbers not containing a $$2$$ or $$4$$ is $$4^n$$ each, and the count of those not containing either is $$3^n$$. Thus the required answer is $$5^n-2\cdot4^n+3^n$$.