If I am given a number, for example 6, what's the mathematical algorithm for finding the smallest positive integer with 6 factors. It will be 12, but I need a formula which can give me the answers for higher number of factors such as 18.
I'm confused with this. A clear explanation would be appreciated.
The number of positive divisors of $n=p_1^{a_1}p_2^{a_2}\cdots p_k^{a_k}$ (where the $p_i$ are distinct primes and the $a_i$ positive integers) is $(a_1+1)(a_2+1)\cdots (a_k+1)$. For the smallest $n$ with a given number of factors, we will have that $p_1,\ldots, p_k$ are the first $k$ primes without gap, wlog in ascending order, i.e., $p_1=2$, $p_2=3$, $p_3=5$, etc. (because if there were a gap, replacing the largest used prime with the smaller, left-out prime would make $n$ smaller). And then we have $a_1\ge a_2\ge\ldots \ge a_k$ (again, because otherwise swapping exponents would make $n$ smaller: $p^aq^b<p^bq^a$ if $p<q$ and $a>b$). The possible choices for the $a_i$ now come from the factorization of the desired number of divisors.
For $18$ divisors, the factorizations of $18$ into one or more non-increasing factors are $$18=9\cdot 2 =6\cdot 3,$$ leading to the candidate numbers $$ 2^{17},\quad 2^83^1,\quad 2^53^2.$$ Among these, $$ 2^53^2=288$$ is the smallest.