If you fix $m$, this is known as the $m$-dimensional multiplication problem. In 2010 Koukoulopoulos showed that as $n\rightarrow \infty$ $$P(m,n)=\left|\lbrace a_1\cdots a_m\ :\ a_i\leq n \text{ for all } \ i\rbrace\right|\asymp \frac{n^{m+1}}{(\log n)^{c_m}(\log\log n)^{3/2}}$$ where $$c_{m}=\int_{1}^{\frac{k}{\log(m+1)}}\log x\text{d}x=\frac{\log(m+1)+m\log\left(m\right)-m\log\log(m+1)-m}{\log(m+1)}.$$ See [this answer for more details][1]. For $m\rightarrow \infty$, and $n$ fixed your calculations show that the order of magnitude looks like $m^{\pi(n)}$ where $\pi(n)=\sum_{p\leq n}1$ denotes the number of primes less that $n$. By considering those primes $p\leq n$, it is easy to see that we have a lower bound for $P(n,m)$ of this form. In what follows, by using [Rankin's trick][2] I will obtain the bound $$P(n,m)\leq m^{\pi(n)} e^{2n}\ \ \ \ \ \ \ \ \ \ \ (1) $$ which holds for any $m$ and $n\geq 3$. (Of course this bound is only strong when $n$ is very small compared to $m$) From this, it follows that for $n$ fixed and $m\rightarrow \infty$ we obtain the correct order of magnitude $$P(n,m)\asymp m^{\pi(n)}.$$ Notice that every element in your set lies in ${1,\dots,n^m}$, and has no prime factor larger than $n$. Let $S(y)=\{n\in\mathbb{Z}:P(n)\leq y\}$ where $P(n)$ is the largest prime factor of $n$. Then $$P(n,m)\leq \sum_{\begin{array}{c} k\leq n^{m}\\ k\in S(n) \end{array}}1.$$ For any $\sigma>0$, since $\sum_{n=1,\ n\in S(y)}^\infty n^{-\sigma}=\prod_{p\leq y} \left(1-1/p^\sigma\right)^{-1}$, we have that $$P(n,m)\leq \sum_{\begin{array}{c} k\leq n^{m}\\ k\in S(n) \end{array}}\frac{n^{\sigma m}}{k^\sigma}=n^{\sigma m} \prod_{p\leq n}\left(1-\frac{1}{p^\sigma}\right)^{-1}.$$ Since $1-p^{-\sigma}\geq\frac{\sigma\log p}{2}$, it follows that $$\prod_{p\leq n}\left(1-p^{-\sigma}\right)^{-1}\leq2^{\pi(n)}\sigma^{-\pi(n)}\prod_{p\leq n}\frac{1}{\log p}\leq2^{\pi(n)}\sigma^{-\pi(n)}. $$ Choosing $\sigma=\pi(n)/m$, it follows that $$P(n,m)\leq m^{\pi(n)}n^{\pi(n)}2^{\pi(n)}\pi(n)^{-\pi(n)}.$$ Applying the Brun-Titchmarsh theorem, we obtain equation $(1)$ for all $m,n$ with $n\geq 3$. [1]: https://mathoverflow.net/questions/108912/number-of-elements-in-the-set-1-cdots-n-times-1-cdots-n/108939#108939 [2]: https://math.stackexchange.com/questions/483027/numbers-divisible-by-the-square-of-their-largest-prime-factor