# How many triangular numbers have exactly $d$ divisors?

The triangular numbers $$T_n$$ are defined by $$T_n = \frac{n(n + 1)}{2}.$$

Given a positive integer $$d$$, how many triangular numbers have exactly $$d$$ divisors, and how often do such numbers occur?

For $$d = 4, 8$$ the answer seems to be "infinitely many, and often"; for $$d = 6$$, it seems to be "infinitely many, but rarely"; and for $$d \geq 3$$ prime the answer is "none" (I think I can prove this). Given $$d$$ such that there are infinitely many such triangular numbers, can we say anything about the asymptotic gaps between them?

Here is a plot of the number of divisors of $$T_n$$ as $$n$$ ranges from $$0$$ to $$50,000$$:

The OEIS contains some sequences related to this question, namely A292989 and A068443, but I can't learn enough from the comments there to settle this question for arbitrary $$d$$.

Edit: The "none" claim for prime $$d$$ only holds when $$d > 2$$, as @BarryCipra pointed out.

• An interesting question to ask is are there any number with odd number of divisors. One example is ${{1681\times 1682} \over 2} = 1413721$ which is a square number itself and has $9$ divisors. I think this might actually be the only example. – cr001 Feb 7 '19 at 16:07
• @cr001: The only numbers with an odd number of divisors are square numbers. The triangular numbers which are also square are given at oeis.org/A001110 – Michael Lugo Feb 7 '19 at 16:20
• @cr001 There is also $n = 8$ and $n = 49$, in addition to your numbers. I agree with you and suspect that each odd number of divisors has only finitely many examples. – Robert D-B Feb 7 '19 at 16:21
• See oeis.org/A063440 . The comments there give conditions for $\sigma_0(T_n) = 4$ and $\sigma_0(T_n) = 6$. The conditions for 4 seem "easier" than the conditions for 6, although I'm having trouble making this precise. – Michael Lugo Feb 7 '19 at 16:29
• Let $a(n) = \sigma_0(T_n)$. It seems more generally true that $a(n)$ is usually a multiple of 4, from the data at A063440. The comments at A063440 give $a(2k) = \sigma_0(k) \sigma_0(2k+1)$ and $a(2k+1) = \sigma_0(2k+1) \sigma_0(k+1)$. The function $\sigma_0$ takes even values except when its argument is square, so $a(n)$ is almost always a mulitple of 4. – Michael Lugo Feb 7 '19 at 16:36

This is a partial answer. Write $$\sigma_0(k)$$ for the number of divisors of $$k$$. Note that $$n$$ and $$n+1$$ are relatively prime. If $$\sigma_0(T_n)$$ is odd, then either $$n$$ is even and both $$\frac{n}{2}$$ and $$n+1$$ are squares or $$n$$ is odd and both $$n$$ and $$\frac{n+1}{2}$$ are squares (note that in particular this implies that in the first case $$n\equiv 0\mod{8}$$ and in the second $$n\equiv 1\mod{8}$$). Simplifying, one sees that odd values of $$\sigma_0(T_n)$$ arise from solutions to the Pell equation $$a^2-2b^2 = \pm 1.$$ So there are an infinite number of $$n$$ for which $$\sigma_0(T_n)$$ is odd. However, since $$\sigma_0$$ is multiplicative, $$\sigma_0(T_n)$$ cannot be prime unless $$n=2$$.
Next, note that $$\sigma_0(T_n)=4$$ means that either $$n$$ is even and $$\sigma_0\left(\frac{n}{2}\right) = \sigma_0(n+1) = 2$$, or $$n$$ is odd and $$\sigma_0(n) = \sigma_0\left(\frac{n+1}{2}\right) = 2$$. Thus $$\sigma_0(T_n)=4$$ if and only if either $$\frac{n}{2}$$ and $$n+1$$ are both prime or if $$n$$ and $$\frac{n+1}{2}$$ are both prime. The first of these is A005097; the second is A006254.
A similar analysis shows that $$\sigma_0(T_n)=6$$ requires that one of the two factors (i.e., either $$\frac{n}{2}$$ and $$n+1$$, or $$n$$ and $$\frac{n+1}{2}$$) be prime and the other be the square of a prime, so the values of $$n$$ below $$200$$ are $$n=7, 9, 17, 18, 25, 97, 121$$. These are presumably rarer than the values for $$\sigma_0(T_n)=4$$.
In response to the OP's comment below, for fixed odd $$d$$, both factors must be squares in order that $$\sigma_0$$ be odd for each. If $$T_n = 2\prod p_i^{2r_i}$$, then you are looking for a way to write $$\prod p_i^{2r_i} = \prod p_i^{2s_i}\prod p_i^{2t_i}$$ such that $$\prod(s_i+1)\prod(t_i+1) = d$$. This doesn't seem like a problem with a straightforward solution in general.
• I see that this implies that there are infinitely many odd $d$ for which we can find $n$ that works. Does this method tell us anything about fixed $d$? – Robert D-B Feb 7 '19 at 16:26
• After some searching, I suspect actually there might be infinitely many solution for at least $d=9$. Apparently given a pair of solutions $(x,y)=(41, 29)$ for example the next solution can be constructed using $(3x+4y, 2x+3y)$ and the iff condition for infinite $d=9$ is such pairs being both prime numbers infinitely many times. And this looks pretty much true to me. – cr001 Feb 7 '19 at 17:09