%I #30 May 04 2024 11:58:07
%S 1,1711,105111,6271111,664611111,222222111111,22222221111111,
%T 2222222211111111,2517912111111111,18428299161111111111,
%U 2222222222211111111111,222222222222111111111111,22222222222221111111111111,1090161504430911111111111111
%N Smallest triangular number ending in n ones.
%C If a triangular number ends in like digits then it can only end in 0's, 1's, 5's or 6's.
%C The sequence is infinite because the sequence of triangular numbers 21, 2211, 222111, 22221111, ... (A319170) is infinite.
%H Chai Wah Wu, <a href="/A227218/b227218.txt">Table of n, a(n) for n = 1..501</a> (terms 1..200 from Giovanni Resta)
%e a(2) = 1711 because 1711 is the smallest triangular number ending in 2 '1's.
%t t = {}; Do[Do[x = n*(n + 1)/2;If[Mod[x, 10^m] == (10^m - 1)/9, AppendTo[t, x]; Break[]], {n, 1, 10^m}], {m, 1, 10}]; t
%t a[n_] := Block[{x, y, s}, s = y /. List@ ToRules[ Reduce[(y+1)* y/2 == x*10^n +(10^n - 1)/9 && y > 0 && x >= 0, {y, x}, Integers] /. C[1] -> 0]; Min[s*(s + 1)/2]]; Array[a, 20] (* _Giovanni Resta_, Sep 20 2013 *)
%o (Python)
%o from sympy import sqrt_mod_iter
%o def A227218(n):
%o k, a = 10**n<<1, (10**n-1)//9<<1
%o m = (a<<2)+1
%o return min(b for b in ((d>>1)*((d>>1)+1) for d in sqrt_mod_iter(m, k) if d&1) if b%k==a)>>1 # _Chai Wah Wu_, May 04 2024
%Y Cf. A000217, A187127, A227219, A227220, A319170.
%K nonn,base
%O 1,2
%A _Shyam Sunder Gupta_, Sep 19 2013
%E a(11)-a(14) from _Giovanni Resta_, Sep 20 2013