The problem asks for the least number $N$ such that the number of divisors of $N$ is at least $n+2$. Since all numbers below $N$ must have fewer divisors, clearly $d(N) > d(m)$ for all $1\le m < N$. Such a champion value $N$ for the divisor function was termed by [Ramanujan][1] as a highly composite number, and he determined the prime factorization of such numbers. Every such $N$ may be written as $$ N = 2^{a_2} 3^{a_3} \cdots p^{a_p} $$ where the exponents satisfy $a_2 \ge a_3 \ge \ldots \ge a_p\ge 1$. Apart from $4$ and $36$, the last exponent $a_p =1$. Ramanujan's main result concerns the exponents $a_\ell$ for primes $\ell \le p$. He works out detailed estimates for these exponents; roughly they satisfy $$ a_\ell \approx \frac{1}{\ell^{\alpha}-1}, $$ with $\alpha= \log 2/\log p$, in keeping with Will Sawin's answer. But the approximation is not as tight as claimed in Will's answer (which is inaccurate). The numbers produced in Will Sawin's answer are what Ramanujan calls "superior highly composite numbers." These numbers $N$ are characterized by the property that for some $\epsilon >0$ one has $$ \frac{d(N)}{N^{\epsilon}} > \frac{d(n)}{n^{\epsilon}}, $$ for all $n >N$, and $$ \frac{d(N)}{N^{\epsilon}} \ge \frac{d(n)}{n^{\epsilon}} $$ for all $n\le N$. The "superior highly composite numbers" are strictly a subset of the highly composite numbers. The table on pages 110-112 of Ramanujan's paper lists all the highly composite numbers (with superior highly composite numbers marked with an asterisk) with number of divisors up to $10080$ (that is, Ramanujan computes your $f(n)$ for all $n\le 10078$). Ramanujan says "I do not know of any method for determining consecutive highly composite numbers except by trial," but of course someone who computed this table may be reasonably assumed to be in possession of an algorithm (perhaps not too different from what Timothy Chow suggested). <hr /> [![Ramanujan][2]][2] <br /> <sup> The beginning of Ramanujan's table. </sup> <hr /> [1]: http://ramanujan.sirinudi.org/Volumes/published/ram15.pdf [2]: https://i.sstatic.net/SSwmp.jpg