WorksMathematics
Sums of three composite triangular numbers
Abstract
A triangular number T_k = k(k+1)/2 is composite for every k >= 3, the only non-composite ones being 0, 1 and 3. We ask which integers are sums of three composite triangular numbers, a restricted form of Gauss's Eureka theorem; equivalently, when 8n+3 is a sum of three squares none of which is 1, 9 or 25. We prove that every integer n > 194 is a sum of three composite triangular numbers, with at most three possible exceptions, all larger than 8.410^9. Such exceptions can occur only if Tatuzawa's form of Siegel's theorem, with eps = 1/20, has an exceptional discriminant -N, and then only for 8n+3 in {N*, 9N*, 25N*}. Up to 8.410^9 the integers that are not such sums are exactly 41 explicit values, the largest being 194. Under the Generalized Riemann Hypothesis these 41 values are the complete list. The proof combines an elementary lemma, a union bound for the representations that use a forbidden square, the class number formula for sums of three squares, Tatuzawa's theorem, and explicit bounds for a divisor-type function. The analytic range begins at 8n+3 = 3.456110^10 and overlaps the computed range by a factor 1.944. The computed range is certified by two independent algorithms, supplied as ancillary files together with a verifier for every constant.
Introduction
Gauss’s Eureka theorem states that every non-negative integer is a sum of three triangular numbers , ; it is equivalent to the representation of every as a sum of three squares. Since or is a product of two integers larger than 1 as soon as , the only triangular numbers that are not composite are , and . It is natural to ask how much of Gauss’s theorem survives when these three are removed.
Definition 1.1. Let be the set of integers that cannot be written with .
Theorem 1.2. (i) The elements of not exceeding are exactly
forty-one values, the largest being 194.
(ii) Every element of larger than is of the form with , where is the exceptional discriminant allowed by Lemma 5.1 with , if there is one. In particular has at most 44 elements, and every is a sum of three composite triangular numbers with at most three possible exceptions.
The exceptional discriminant may well not exist; if it exists, it need not be , in which case part (ii) gives no exception at all. What the theorem cannot do is decide this, which is the familiar limitation of every effective form of Siegel’s theorem. Under the Generalized Riemann Hypothesis the question disappears.
Corollary 1.3. Assume the Generalized Riemann Hypothesis, in the form used in [8] and [9]. Then consists exactly of the 41 values listed in Theorem 1.2; every integer is a sum of three composite triangular numbers.
The closest result in the literature concerns sums of three nonzero triangular numbers, that is, the exclusion of alone. Kim, Lee and Oh [8] proved, under the Generalized Riemann Hypothesis, that every positive integer except 1, 2, 4, 6, 11, 20, 29 is such a sum. Excluding , and amounts to excluding the three odd squares 1, 9, 25 instead of the single square 1. Their result enters our proof of Corollary 1.3, through Proposition 2.3. We are not aware of an earlier treatment of the present question. The recent historical survey of Aygin and Williams [1] is the natural place where one would be recorded; its abstract concerns formulas for the number of representations, and we have not been able to consult the full text.
Plan. Section 2 states the problem in terms of sums of three squares and treats every divisible by the square of an odd . Section 3 shows that the remaining cases follow from the inequality between a class number and a divisor-type function. Section 4 bounds that function, and Section 5 recalls Tatuzawa’s lower bound for the class number. Section 6 closes the chain of ranges, Section 7 proves Corollary 1.3, and Section 8 describes the computation and the ancillary files. Section 9 states precisely what rests on what.
Reformulation and the elementary range
Lemma 2.1. Put . Then with if and only if with odd, the correspondence being , and similarly for . Every representation of as a sum of three squares has odd. Consequently if and only if with , that is, with none of equal to 1, 9 or 25.
Proof. The identity gives . Squares are 0, 1 or 4 modulo 8, and three of them sum to 3 modulo 8 only as , so are odd. An odd is with , and exactly when ; the odd squares below 49 are 1, 9 and 25.
Proposition 2.2. If for some odd , then .
Proof. Every odd square is , so . By Gauss’s theorem , and by Lemma 2.1 are odd, hence non-zero. Then with .
Proposition 2.3. Let and suppose . If is a sum of three nonzero triangular numbers, then .
Proof. If with , then with , and similarly for . Hence with .
Write with squarefree and ; is odd. If , then and Proposition 2.2 applies with . Since , the number is a fundamental discriminant. From now on .
The counting inequality
Let be the number of ordered triples with and , and the number of ordered pairs with and (with for ).
Lemma 3.1. Let as above, with . Then
where counts representations as a sum of three squares and is the class number of primitive positive definite binary quadratic forms of discriminant $-d^2N_0. In particular
where is the Kronecker character of ; hence .
Proof. By Lemma 2.1 each triple corresponds to exactly 8 representations of , one for each choice of signs, so . For , Gauss’s theorem on primitive representations [4 art. 291–292], see also [5], gives primitive representations of ; summing over the squares , that is over with , gives . The class number of the order of conductor is , the unit index being 1 since [2 Section 7]; for and this is and .
:::
Lemma 3.2. For , , where is the number of divisors of congruent to modulo 4. Consequently
Proof. is . Every representation of as a sum of two squares has both terms odd, so the pairs are the representations with both terms positive, that is . By Jacobi’s formula [6 Thm. 278], , and the odd divisors of are those of . The last assertion is the usual evaluation of as a multiplicative function: it vanishes unless every prime occurs to an even power, and then equals the product.
Proposition 3.3. If , then .
Proof. For and , let be the set of triples counted by whose -th entry is . Then , and . A triple outside has all entries . Such a triple exists as soon as
:::
Definition 3.4. For let
The three integers , , attached by Lemma 3.2 to , , are at most . Since is non-decreasing, Proposition 3.3 gives:
:::`
Corollary 3.5. If , then .
Remark 3.6. The union bound in Proposition 3.3 is crude: a triple with two forbidden entries is counted twice. Inclusion–exclusion would improve the constants of Section 6, but the chain closes without it, and the cruder form is easier to check.
The function
Let be the primes , and write .
Lemma 4.1. For every , is the maximum of over the integers
Proof. Given , delete its prime factors , then assign the exponents of the remaining primes, in non-increasing order, to . The value does not change and, by the rearrangement inequality, the integer does not increase.
The integers of Lemma 4.1 up to involve at most eight primes, since , and are enumerated exhaustively by the ancillary verifier. The records that matter are in Table 1; the enumeration is checked against a brute-force scan of all .
| smallest | factorisation | |
| 96 | 243 061 325 | |
| 128 | 1 215 306 625 | |
| 144 | 3 159 797 225 | |
| 160 | 6 076 533 125 | |
| 192 | 12 882 250 225 | |
| 216 | 53 716 552 825 |
Table 1. Records of : first reaches the value in the first column at .
In particular
Lemma 4.2. For put . Then for all . Moreover , the maxima being attained at for .
Proof. For , , the products running over . If then . The numerical value is computed by the verifier.
Tatuzawa's theorem
Lemma 5.1 (Tatuzawa). Let . There is at most one fundamental discriminant with such that
This is [10 Theorem 2], proved there from Lemma 9; it is restated by Elsenhans, Klüners and Nicolae [3 Lemma 2] and used by Hopkins and Stopple [7]. We take , so that . If is a fundamental discriminant with , then, by the class number formula ,
Here and below, denotes the exceptional discriminant of Lemma 5.1 for , if there is one.
Remark 5.2. The proof requires the form of Lemma 5.1, with the constant , as given in [10 Theorem 2].
Proof of Theorem 1.2
Let with , squarefree, and suppose . By Lemma 3.1 and (2), as long as ,
since and . By Corollary 3.5 it is therefore enough to have
The condition holds throughout the analytic ranges below, which start at , so that .
Range 1: . By Lemma 4.2 with , , so (3) holds as soon as
that is .
Range 2: . Here , so by (1), and (3) holds as soon as , that is
Range 2 extends beyond the start of Range 1, so Ranges 1 and 2 together cover every , that is every .
Range 3: . By direct computation (Section 8), the elements of up to , that is with , are exactly the 41 values of part (i).
Closure. Ranges 2 and 3 overlap, by the factor
Hence every with lies outside . The remaining integers have , which is part (ii). Part (i) is the computation.
Remark 6.1. The factor 1.9444 is the whole of the slack between the analytic and the computed ranges: a factor 2 lost in (3) would separate them. Every constant entering the chain is recomputed in the ancillary verifier in 50-digit decimal arithmetic, with replaced by an upper bound so that (2) is never overstated, and the closure of the chain is checked by assertions.
Proof of Corollary 1.3
By Theorem 1.2 it suffices to show that, under GRH, no with lies in .
If with , then , say , and . By the theorem of Kim, Lee and Oh [8 Cor. 3.11], valid under GRH, is a sum of three nonzero triangular numbers, and Proposition 2.3 gives .
If , then . Under GRH, Lamzouri, Li and Soundararajan [9 Thm. 1.5] prove, for every primitive character modulo ,
At this gives , while the exceptional inequality of Lemma 5.1 would require ; the ratio between the two bounds is at least 9.54 for every , since the first decreases only like while the second decreases like . Hence does not exist in this range.
Computation
The ancillary file VERIFY_range.py recomputes by two algorithms that share no code except an exact test used on rare survivors. Both work on segments of consecutive integers.
Method A. On each segment, the set of sums with is built on a window reaching just below the segment, and is declared covered as soon as lies in it for one of the 64 composite triangular numbers .
Method B. The set of sums with is built once on , and is declared covered as soon as lies in it for some . For this test is exhaustive.
Every integer that is not declared covered is passed to an exact test, which tries every and decides whether is a sum of two composite triangular numbers; the exceptions are therefore certified by exhaustion. As a guard against a marking error, 24 integers declared covered are drawn at random in each segment and re-tested exactly. Up to , method A passes 368 integers to the exact test and method B passes 16 341; both return exactly the 41 values of Theorem 1.2 (i). The two runs together take about six and a half minutes on two cores.
The file VERIFY_composite_triangular.py recomputes the exceptional set up to by a third implementation, the records of (Table 1) by the enumeration of Lemma 4.1 checked against a brute-force scan up to , the constants , , the thresholds and the overlap of § 6, and the identities of Lemma 3.1 for (), () and (), with class numbers computed by counting reduced forms. The files CHECK_classnumbers.magma and CHECK_exceptions.magma repeat the class number identities and the exceptional set up to under Magma, with Magma’s own class number routine. Both Python files require only Python 3 and numpy, and take no input.
As consistency checks, none of the 41 exceptions has divisible by with odd, as Proposition 2.2 requires; and the six exceptions with or , namely , give in Proposition 2.3, all of them on the list of Kim, Lee and Oh.
Status of the argument
Proved here: Lemmas 2.1, 3.2, 4.1, 4.2, Propositions 2.2, 2.3, 3.3, and the deduction of Theorem 1.2 (ii) and Corollary 1.3 from the inputs below.
Verified by computation: the 41 exceptions up to ; the records of ; the constants and the closure of the chain; the identities of Lemma 3.1 on the ranges stated.
Quoted: Gauss’s formula for and the class number of orders (Lemma 3.1); Jacobi’s formula for ; Tatuzawa’s theorem (Lemma 5.1), checked against the original [10 Theorem 2]; and, for Corollary 1.3 only, [8 Cor. 3.11] and [9 Thm. 1.5], both conditional on GRH.
Open: whether the exceptional discriminant can be excluded unconditionally, which would make the list of 41 values complete without any reserve.
Acknowledgements. Technical assistance: Claude (Anthropic).
References
- [1]Z. S. Aygin and K. S. Williams, Historical survey of sums of three squares, Expo. Math. 44 (2026), no. 3, article 125776. doi:10.1016/j.exmath.2026.125776.DOI
- [2]D. A. Cox, Primes of the Form x² + ny²: Fermat, Class Field Theory, and Complex Multiplication, Wiley, New York, 1989.
- [3]A.-S. Elsenhans, J. Klüners and F. Nicolae, Imaginary quadratic number fields with class groups of small exponent, Acta Arith. 193 (2020), 217–233. doi:10.4064/aa180220-20-3.DOI
- [4]C. F. Gauss, Disquisitiones Arithmeticae, Leipzig, 1801.
- [5]E. Grosswald, Representations of Integers as Sums of Squares, Springer, New York, 1985. doi:10.1007/978-1-4613-8566-0.DOI
- [6]G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, Oxford University Press.
- [7]K. Hopkins and J. Stopple, Lower bounds for the principal genus of definite binary quadratic forms, Integers 10 (2010). doi:10.1515/integ.2010.021.DOI
- [8]D. Kim, J. Lee and B.-K. Oh, A sum of three nonzero triangular numbers, Int. J. Number Theory 17 (2021), no. 10, 2279–2300. doi:10.1142/S1793042121500883.DOI
- [9]Y. Lamzouri, X. Li and K. Soundararajan, Conditional bounds for the least quadratic non-residue and related problems, Math. Comp. 84 (2015), no. 295; Corrigendum, Math. Comp. 86 (2017), 2551–2554. Corrected version: arXiv:1309.3595v3.arxiv.org/abs/1309.3595
- [10]T. Tatuzawa, On a theorem of Siegel, Japan. J. Math. 21 (1951), 163–178. doi:10.4099/jjml1924.21.0_163.DOI