<s>[INST] For a natural number $b$, let $N(b)$ denote the number of natural numbers $a$ for which the equation $x^2+ax+b=0$ has integer roots. 
For a natural number $b$, let $N(b)$ denote the number of natural numbers $a$ for which the equation $x^2+ax+b=0$ has integer roots. What is the smallest value of $b$ for which $N(b)=20$.

I came across a similar problem at: For a natural number $b$, $N(b)=$ number of natural numbers a such that the equation $x^2+ax+b=0$ has integral roots.
But, there it is asked to find $N(b)$ given value of $b=6$. Here, the opposite is asked, to find $b$ given $N(b)$.
How can I proceed here?
 [/INST] First, observe that, for all $a, b \in \mathbb{Z}$, the polynomial $X^{2} +a X +b \in \mathbb{Z}[X]$ has integer roots if and only its discriminant $\Delta = a^{2} -4 b$ is the square of an integer:

*

*if there exists $\delta \in \mathbb{Z}$ such that $\Delta = \delta^{2}$, then $\delta$ and $a$ have the same parity since they both have the same parity as $\Delta$, and hence the roots $x_{1} = \frac{a -\delta}{2}$ and $x_{2} = \frac{a +\delta}{2}$ of this polynomial are integers;

*Conversely, if this polynomial has integer roots $x_{1}, x_{2}$ (repeated according to their multiplicities), then $\Delta = \left( x_{1} -x_{2} \right)^{2}$ is the square of an integer.

Let $b \geq 1$ be an integer. Define $$S(b) = \left\lbrace a \in \mathbb{Z}_{\geq 0} : \exists \delta \in \mathbb{Z}, \, a^{2} -4 b = \delta^{2} \right\rbrace \, \text{,}$$ so that $N(b) = \left\lvert S(b) \right\rvert$ by the discussion above. Let us describe this set $S(b)$.

*

*Suppose that $a \in S(b)$. There exists $\delta \in \mathbb{Z}$ such that $a^{2} -4 b = \delta^{2}$. Then $a$ and $\delta$ have the same parity, and hence $a -\delta$ and $a +\delta$ are both even. Moreover, we have $\left( \frac{a -\delta}{2} \right) \left( \frac{a +\delta}{2} \right) = b$. Therefore, there exists a divisor $d$ of $b$ such that $\frac{a -\delta}{2} = d$ and $\frac{a +\delta}{2} = \frac{b}{d}$, and we have $a = d +\frac{b}{d}$, which also shows that $d$ is positive.

*Conversely, suppose that there exists a positive divisor $d$ of $b$ such that $a = d +\frac{b}{d}$. Then we have $a^{2} -4 b = \left( d -\frac{b}{d} \right)^{2}$, and hence $a \in S(b)$.

Thus, we have proved that $$S(b) = \left\lbrace d +\frac{b}{d} : d \text{ is a positive divisor of } b \right\rbrace \, \text{.}$$
Now, note that, for all positive divisors $d_{1}, d_{2}$ of $b$, we have
\begin{align*}
d_{1} +\frac{b}{d_{1}} = d_{2} +\frac{b}{d_{2}} & \Longleftrightarrow d_{1}^{2} d_{2} +b d_{2} = d_{1} d_{2}^{2} +b d_{1}\\
& \Longleftrightarrow \left( d_{1} -d_{2} \right) \left( d_{1} d_{2} -b \right) = 0\\
& \Longleftrightarrow d_{2} = d_{1} \text{ or } d_{2} = \frac{b}{d_{1}} \, \text{.}
\end{align*}
Moreover, for every positive divisor $d$ of $b$, we have $d = \frac{b}{d}$ if and only if $b = d^{2}$. Therefore, we have $$N(b) = \begin{cases} \frac{\sigma(b) +1}{2} & \text{if } b \text{ is a square}\\ \frac{\sigma(b)}{2} & \text{otherwise} \end{cases} \, \text{,}$$ where $\sigma(b)$ denotes the number of positive divisors of $b$.
Finally, let us find the least integer $b \geq 1$ such that $N(b) = 20$. By the discussion above, for every $b \geq 1$, we have $N(b) = 20$ if and only if $\sigma(b) \in \lbrace 39, 40 \rbrace$ (note that $b$ is a square if and only if $\sigma(b)$ is odd). Recall that, for all pairwise distinct primes $p_{1}, \dotsc, p_{r}$ and all $m_{1}, \dotsc, m_{r} \geq 1$, we have $$\sigma\left( p_{1}^{m_{1}} \dotsm p_{r}^{m_{r}} \right) = \left( m_{1} +1 \right) \dotsm \left( m_{r} +1 \right) \, \text{.}$$ Morevover, $39 = 3 \cdot 13$ and $40 = 2^{3} \cdot 5$. Therefore, the integers $b \geq 1$ such that $N(b) = 20$ are precisely the numbers of the form $$p_{1} p_{2} p_{3} p_{4}^{4} \, \text{,} \quad p_{1} p_{2} p_{3}^{9} \, \text{,} \quad p_{1} p_{2}^{3} p_{3}^{4} \, \text{,} \quad p_{1} p_{2}^{19} \, \text{,} \quad p_{1}^{2} p_{2}^{12} \, \text{,} \quad p_{1}^{3} p_{2}^{9} \, \text{,} \quad p_{1}^{4} p_{2}^{7} \, \text{,} \quad p_{1}^{38} \quad \text{or} \quad p_{1}^{39} \, \text{,}$$ where $p_{1}, p_{2}, p_{3}, p_{4}$ are pairwise distinct prime numbers. Thus, the least integer $b \geq 1$ such that $N(b) = 20$ is $2^{4} \cdot 3 \cdot 5 \cdot 7 = 1680$.
</s>