A052218 Numbers whose sum of digits is 4.
4, 13, 22, 31, 40, 103, 112, 121, 130, 202, 211, 220, 301, 310, 400, 1003, 1012, 1021, 1030, 1102, 1111, 1120, 1201, 1210, 1300, 2002, 2011, 2020, 2101, 2110, 2200, 3001, 3010, 3100, 4000, 10003, 10012, 10021, 10030, 10102, 10111, 10120, 10201, 10210, 10300
Offset: 1
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..10000 (terms 1..1001 from Vincenzo Librandi and T. D. Noe, terms 1..201 from Vincenzo Librandi)
Crossrefs
Programs
-
Haskell
a052218 n = a052218_list !! (n-1) a052218_list = filter ((== 4) . a007953) [0..] -- Reinhard Zumkeller, Jul 17 2014
-
Magma
[n: n in [1..10300] | &+Intseq(n) eq 4 ]; // Vincenzo Librandi, Mar 07 2013
-
Mathematica
Select[Range[10^5], Total[IntegerDigits[#]] == 4 &] (* Vincenzo Librandi, Mar 07 2013 *) Union[Flatten[Table[FromDigits /@ Permutations[PadRight[s, 11]], {s, IntegerPartitions[4]}]]] (* T. D. Noe, Mar 08 2013 *)
-
PARI
isok(n) = sumdigits(n) == 4; \\ Michel Marcus, Dec 28 2015
-
Python
from itertools import count, islice def agen(): yield from (10**i + 10**j + 10**k + 10**m for i in count(0) for j in range(i+1) for k in range(j+1) for m in range(k+1)) print(list(islice(agen(), 45))) # Michael S. Branicky, May 15 2022
Extensions
Offset changed from Bruno Berselli, Mar 07 2013
Comments