<s>[INST] How can i find the least number n that can be presented as product of a*b Which the least number n can we imagine in product n = a∙b like k ways? Products a∙b and b∙a is one of the way, where all numbers is natural (1≤ k ≤50)
I tried to loop from 1 to 1000000 and with each number perform the following:
looping from 1 to square root of that number and if number%i==0 then add to one variable and after reaching the square root check if var is equal to k if yes then print i,but this solution took too much time
 [/INST] Suppose $$n=2^{n_1}\cdot 3^{n_2}\dots \cdot p_r^{n_r}$$ where $p_r$ is the $r^{th}$ prime. The number of divisors of $n$ $$d(n)=(n_1+1)(n_2+1)\dots (n_r+1)$$
The number of factorisations is half of this unless $n$ is a square in which case it is half $d(n)+1$.
To find a number having $k$ factorisations, reverse this process. Look at factorisations of $2k$ and allocate the largest factors to the smallest primes. Check also factorisations of $2k-1$.

Suppose $k=2$ we need $d=2k=4$ or $d=2k-1=3$.
If $d=4$ we have either 
(1) the single factor $4$ which gives exponent $4-1=3$ and choose the lowest prime, $2^3=8$ with factorisations $1\cdot 8$ and $2\cdot 4$
(2) The factors $2\cdot 2$ which gives two exponents equal to $2-1=1$. The lowest possibility is $2^13^1=6$ and factorisations $1\cdot 6$ and $2\cdot 3$
If $d=3$ we have just the factor $3$ and exponent $3-1=2$ which gives $2^2=4$ with $1\cdot 4$ and $2\cdot 2$
This tells us that the possible lowest numbers having two factorisations are $4, 6, 8$ - obviously $4$ is the one.

With $k=6$ we have $d=12$ or $d=11$
$d=12$ factorises 
(1) as $12$ giving $2^{11}=2048$ 
(2) $6\cdot 2$ giving $2^5\cdot 3=96$ 
(3) $4\cdot 3$ giving $2^3\cdot 3^2=72$ 
(4) $3\cdot 2 \cdot 2$ giving $2^2\cdot 3\cdot 5=60$
$d=11$ gives just $2^{10}=1024$
Clearly $60$ is the number you want.

In this last case, how do we count the factors of $60$?
Well with the prime $2$ we have three possible factors $1,2,4$
With the prime $3$ we get $1,3$
With the prime $5$ we get $1,5$
We need to choose one factor associated with each of the primes, hence $3\times 2\times 2=12$ possibilities.

How do we know we got all the possibilities for $12=2^2\cdot 3^1$. Well this gives $d=6$ and $k=3$ for two factor factorisations, and there is just the fourth possibility $2\cdot 2\cdot 3$ - we got them all.
</s>