login
Numbers k with the property that k ends in the sum of the digits of k.
3

%I #20 Apr 19 2022 19:03:14

%S 1,2,3,4,5,6,7,8,9,910,911,912,913,914,915,916,917,918,919,1810,1811,

%T 1812,1813,1814,1815,1816,1817,1818,1819,2710,2711,2712,2713,2714,

%U 2715,2716,2717,2718,2719,3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,4510,4511,4512,4513,4514,4515,4516

%N Numbers k with the property that k ends in the sum of the digits of k.

%H Harvey P. Dale, <a href="/A352462/b352462.txt">Table of n, a(n) for n = 1..1000</a>

%e a(10) = 910, which ends in 10 = 9 + 1 + 0.

%e a(20) = 1810, which ends in 10 = 1 + 8 + 1 + 0.

%e a(39) = 2719, which ends in 19 = 2 + 7 + 1 + 9.

%t q[n_] := Module[{d = IntegerDigits[n], s, ds, nds}, s = Plus @@ d; s = IntegerDigits[s]; nds = Length[ds]; ds == d[[-nds ;; -1]]]; Select[Range[4516], q] (* _Amiram Eldar_, Mar 17 2022 *)

%t Select[Range[4516],StringEndsQ[ToString[#],ToString[Plus@@IntegerDigits[#]]]&] (* _Ivan N. Ianakiev_, Mar 18 2022 *)

%t sdkQ[n_]:=Module[{idn=IntegerDigits[n],d},d=IntegerDigits[Total[idn]];d==Take[idn,-Length[d]]]; Select[Range[5000],sdkQ] (* _Harvey P. Dale_, Apr 19 2022 *)

%o (Python)

%o def ok(n): s = str(n); return s.endswith(str(sum(map(int, s))))

%o print([k for k in range(1, 4517) if ok(k)]) # _Michael S. Branicky_, Mar 17 2022

%Y Cf. A052018, A352461.

%K base,nonn

%O 1,2

%A _Eric Angelini_ and _Carole Dubois_, Mar 17 2022