OFFSET
1,1
COMMENTS
Fermat asserted, and Gauss proved, that every number is the sum of three triangular numbers (cf. A002636).
For exactly half of the integers k in 1..11898, decomposing k into triangular numbers by the greedy algorithm (i.e., letting T1 be the largest triangular number <= k, then letting T2 be the largest triangular number <= k-T1, etc.) yields a decomposition of k into three or fewer positive triangular numbers, but for any K > 11898, the greedy algorithm decomposes more than half of the integers k in 1..K into four or more positive triangular numbers.
Even an approach that assigns only T1 "greedily" but allows T2 to be any triangular number will usually not yield a set of three triangular numbers whose sum is k: for more than half of the integers k in 1..K for any K > 40304762, no such sum exists in which the largest of the three triangular numbers is the largest triangular number <= k. The smallest such k is a(1)=20 (see Example section).
For some values of k, there exists no set of three triangular numbers summing to k unless the largest of the three is neither T(m(k)) nor T(m(k)-1); the smallest of these is a(2)=50, for which a solution to T(m(k)-2) + T2 + T3 = k does exist (see Example section).
EXAMPLE
The largest triangular number <= 20 is T(5) = 5*6/2 = 15, and 20 cannot be expressed as the sum of 3 triangular numbers T1 + T2 + T3 if T1=15, but at T1 = T(5-1) = T(4) = 4*5/2 = 10, 20 can be expressed as T(4) + T(4) + T(0) = 10 + 10 + 0, and 20 is the smallest number with this property, so a(1)=20.
The largest triangular number <= 50 is T(9) = 9*10/2 = 45, and 50 can be expressed as T1 + T2 + T3 neither with T1 = T(9) = 45 nor with T1 = T(9-1) = T(8) = 36; however, at T1 = T(9-2) = T(7) = 28, 50 can be expressed as T(7) + T(6) + T(1) = 28 + 21 + 1, and 50 is the smallest number with this property, so a(2)=50.
CROSSREFS
KEYWORD
nonn
AUTHOR
Jon E. Schoenfield, Feb 02 2020
STATUS
approved