login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A062688
Smallest triangular number with digit sum n (or 0 if no such number exists).
5
1, 0, 3, 0, 0, 6, 0, 0, 36, 28, 0, 66, 0, 0, 78, 0, 0, 378, 496, 0, 1596, 0, 0, 8385, 0, 0, 5778, 5995, 0, 8778, 0, 0, 47895, 0, 0, 67896, 58996, 0, 196878, 0, 0, 468996, 0, 0, 887778, 1788886, 0, 4896885, 0, 0, 5897895, 0, 0, 13999986, 15997996, 0, 38997696
OFFSET
1,3
COMMENTS
From Jon E. Schoenfield, Dec 04 2021: (Start)
a(n) = 0 iff n == (2,4,5,7,8) mod 9.
Nonzero terms are not nondecreasing; e.g., a(9)=36 > a(10)=28.
(End)
LINKS
EXAMPLE
66 is the smallest triangular number with digit sum 12, so a(12)=66.
MATHEMATICA
(With[{tbl={#, Total[IntegerDigits[#]]}&/@Accumulate[Range[9000]]}, Table[SelectFirst[ tbl, #[[2]] ==n&], {n, 60}]]/.Missing["NotFound"]->{0, 0})[[;; , 1]] (* Harvey P. Dale, Aug 21 2024 *)
PROG
(PARI) a(n) = if (vecsearch([2, 4, 5, 7, 8], n % 9), return (0)); my(k=1); while (sumdigits(k*(k+1)/2) != n, k++); k*(k+1)/2; \\ Michel Marcus, Dec 12 2021
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Erich Friedman, Jul 04 2001
STATUS
approved