login
Smallest triangular number containing exactly n 1's.
1

%I #23 Sep 09 2024 10:11:12

%S 1,171,1711,105111,1188111,18111171,1111160511,11161151121,

%T 111111101310,11311511141161,121111912011111,11111811011411671,

%U 11101111131911151,11111111111113201,111111312111373411111,1119711111215111121171,111112117111126711111195,1141011111112731111616111

%N Smallest triangular number containing exactly n 1's.

%F a(n) = A000217(A048356(n)). - _Michel Marcus_, Aug 12 2014

%t nsmall = Table[Infinity, 20];

%t For[i = 0, i <= 10^6, i++, p = PolygonalNumber[i];

%t n0 = Count[IntegerDigits[p], 1];

%t If[nsmall[[n0]] > p, nsmall[[n0]] = p]];

%t ReplaceAll[nsmall, Infinity -> "?"] (* _Robert Price_, Mar 22 2020 *)

%t Module[{nn=5*10^6,tr},tr={#,DigitCount[#,10,1]}&/@Accumulate[Range[ nn]]; Table[ SelectFirst[tr,#[[2]]==k&],{k,10}]][[;;,1]] (* The program generates the first 10 terms of the sequence. *) (* _Harvey P. Dale_, Sep 01 2024 *)

%Y Cf. A048356, A036517-A036526.

%K nonn,base

%O 1,2

%A _David W. Wilson_

%E Definition clarified by _Robert Israel_, Aug 10 2014

%E a(15)-a(16) from A048356 by _Michel Marcus_, Aug 12 2014

%E a(17)-a(18) from _Giovanni Resta_, Oct 30 2019