Formula for the number of numbers $\le n$ with same prime factors as $n$? Is there a more concise formula for this? I threw this one together,
$\sum_{j=1}^{n}(\lfloor\frac{n^{j}}{j}\rfloor-\lfloor\frac{n^{j}-1}{j}\rfloor)(\lfloor\frac{j^{n}}{n}\rfloor-\lfloor\frac{j^{n}-1}{n}\rfloor)=$ number of numbers $\le n$ with same prime factors as $n$.
I can show this by proving that the term in the left parenthesis is only $1$ or $0$ depending on whether or not $j|n^{j},$ which can only happen if the factors in prime factorization of $j$ are a subset of $n$'s. The function in the parenthesis on the right is $1$ or $0$ depending on whether or not $n|j^{n},$ which only occurs if $j$ is a multiple of $rad(n)$, the product of the distinct prime factors of $n$. So, the sum counts the number of numbers $j\le n$ whose prime factorization is a subset of $n$'s and is a multiple of $rad(n)$. This leaves only those with the same factors. I give this info on the sum because people always ask, but I really just need another version.
I'm looking for a different representation of this function than the one I have created above. I can't find a formula for this anywhere. Anybody got one?
Example of the function is, for $n=24$, the prime factors of $24$ are $2$ and $3$. There are $4$ numbers with these factors $\le n,$ which are $(6,12,18,24),$ so the function at $24=4.$ Sequence is A008479 in oeis, but no formula.
 A: Let $\omega(n)$ (OEIS A001221) represent the number of distinct prime factors of $n$. Then a (fairly) transparent expression for what you want is
$$\sum_{1 \leqslant k \leqslant n} [\omega(k) = \omega(n) = \omega(\gcd(k,n))],$$
where $[\cdot]$ is the Iverson bracket, equal to $1$ when the condition inside is satisfied and $0$ otherwise. So we're tallying up the $k$s which have precisely the same number of prime factors as $n$ and no extra ones. Note that $\operatorname{lcm}$ would work just as well: $\omega(\gcd(k,n))$  is the number of distinct prime factors shared by both $k$ and $n$; $\omega(\operatorname{lcm}(k,n))$ is the number of distinct primes present in either $k$ or $n$ or both.
It really is necessary to specify the second equality, otherwise you end up including terms like $15=5 \cdot 3$ for $n=24 = 2^3 \cdot 3$. Notice that $\omega(\operatorname{lcm}(15,24)) = 3 \ne 2$ and $\omega(\gcd(15,24)) = 1 \ne 2$.
Another (perhaps more clear) way is to simply write
$$\sum_{1 \leqslant k \leqslant n} [p | n \Leftrightarrow p | k, \text{ for all prime }p].$$
A: (I prefer the notation $\displaystyle \sum_{j=1}^n 1_{j | n^j} 1_{ n | j^n} $, and using that for integers $\lfloor \frac{a}{b}\rfloor-\lfloor \frac{a-1}{b}\rfloor= 1_{b|a}$, and $rad(n) = \prod_{p | n} p$)  
we get $$1_{ a | b^a} = 1_{ rad(a) | b}  = 1_{ rad(a) | rad(b)}$$  thus 
$$1_{j | n^j} 1_{  n | j^n} = 1_{ rad(j) | rad(n)}1_{ rad(n) | rad(j)} = 1_{ rad(j)= rad(n)}$$
and $rad(j)= rad(n),\ j \le n$ iff $j = d \ rad(n)$ with $rad(d) | rad(n)$ i.e. iff $d | n^d$
 hence $$\displaystyle \sum_{j=1}^n 1_{ j | n^j} 1_{  n | j^n}  = \sum_{j=1}^n 1_{ rad(j) = rad(n)} = \sum_{d=1}^{n/rad(n)} 1_{rad(d)|rad(n)} = \sum_{d=1}^{n/rad(n)} 1_{d | n^d}$$
and I'm not sure there is much simpler anymore, since this $\sum_{d=1}^{n/rad(n)} 1_{rad(d)|rad(n)}$ seems to depend on the precise prime factors of $n$, say if $p | n$, it depends on the maximum power of $p$ that is $\le \frac{n}{rad(n)}$, and hence on the other prime factors of $n$
