Problem
A positive integer is said to be balanced if the number of its decimal digits equals the number of its distinct prime factors. For instance, $15$ is balanced, while $49$ is not. How many balanced numbers are there?
My thoughts
One digit balanced numbers are the prime ones. So, we have $4$ one digit balanced numbers.
Number of 2 digit balanced numbers = number of 2 digit numbers - number of 2 digit prime numbers - number of 2 digit prime powers = $90-21-10=59$.
We can continue doing this until we find no balanced number. But this gets messier in each step.
Edit: As in the comments, I missed many of the numbers.
Is there some easier way to solve the problem?
The total number of these numbers is $7812$.
The number of such $n$ digit numbers $a(n)$ is:
where $a(n)=0,n\gt 10$, as mentioned by Calvin Lin.
It is sufficient to examine products of $n$-subsets of primes. That is, examine square-free numbers. Then, all solutions are numbers that are multiples of these products (possibly increment exponents of individual primes to iterate these multiples without adding excess factors) and also have correct number of digits.
I used python. I'm not sure if there is a pure mathematical approach (no computers).
This python code is not the fastest or prettiest approach, but simply was quick and easy to think of on the spot. Nonetheless, it gets the job done in less than few seconds.
I've also verified these results with a much slower brute force in WA Mathematica.