Clustering numbers by factors count Is there a formula (or an efficient approach) for counting amount of positive numbers in range up to $N$ which have exactly $K$ divisors?
P.S.
Initial problem was to cluster number in range [1..N] according to the number of divisors. Then find multiplication of clusters' sizes factorials.
So we just need compute the answer according to this scheme. 
The final result is a amount of sequencies formed such that first group has 1 divisor, second one has 2 and so on.
 A: While I don't know of an explicit formula giving what you want, there are good ways to simplify the problem.
First, let $\tau(n)$ be the number of divisors of $n$.  If $n=ab$ with $\operatorname{GCD}(a,b)=1$, then every divisor of $n$ can be uniquely factored as a divisor of $a$ and a divisor of $b$.  Because of this, $\tau(ab)=\tau(a)\tau(b)$.  By induction, if we factor $n$ as a product of powers of primes $n=\prod p_i^{a_i}$, then 
$$\tau(n)=\prod \tau(p_i^{a_i})=\prod (a_i+1)$$
because $p^k$ has divisors $1,p,p^2,\ldots p^k$.  Thus, the number of divisors a number has is determined by the exponents of its prime factorization (and not the individual factors).
With this in mind, we can solve the original problem as follows.


*

*Find all possible factorizations of $K$.  Note that there will be $\tau(K)$ of them.

*For each factorization of $K$, subtract $1$ from each of the factors to write $K=\prod (a_i+1)$ for some collection of positive integers $a_i$.  

*For each collection of $a_i$, look at the possible assignment of primes such that $\prod p_i^{a_i}$ is less than $N$.


This is dependent on having a good way to generate all the primes, and the third step probably needs to be fleshed out a little, especially if one wants to be efficient, but overall, this is probably the best approach to the problem.
Note that (as mentioned in the other comments), if you let $K=2$, the problem simplifies to counting the number of primes less than $N$, and so a general formula is going to be more complicated than computing $\pi(N)$.  I don't think anything less involved than the procedure above is likely to be fruitful (although you might be able to get asymptotics for specific values of $K$).  
A: No, there's no such formula.  If there were, then finding new primes would not be an interesting problem.
A: It rather depends on what other functions you have to hand.  
If $K$ is prime then you want to count the primes up to the $K-1^{\text{th}}$ root of $N$, i.e. $$\pi(\sqrt[K-1]{N})$$ where $\pi(x)$ is the prime counting function.  
But for $K=4$ you also want to count the numbers up to $N$  which are the product of distinct primes to add to $\pi(\sqrt[3]{N})$ and I am not aware of an explicit function notation for that.
A: There is another generalization of the problem, according to using of factorials of clusters sizes.
One wants to find amount of permutations of $1..N$ which have the following property -$\tau(A_i)=\tau(i)$, where $A_i$ are the elements of permutation.
