A052219 Numbers whose sum of digits is 5.
5, 14, 23, 32, 41, 50, 104, 113, 122, 131, 140, 203, 212, 221, 230, 302, 311, 320, 401, 410, 500, 1004, 1013, 1022, 1031, 1040, 1103, 1112, 1121, 1130, 1202, 1211, 1220, 1301, 1310, 1400, 2003, 2012, 2021, 2030, 2102, 2111, 2120, 2201, 2210, 2300, 3002
Offset: 1
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..11628 (all terms through 15 digits; terms 1..1287 from Vincenzo Librandi and T. D. Noe, terms 1..462 from Vincenzo Librandi)
Crossrefs
Programs
-
Haskell
a052219 n = a052219_list !! (n-1) a052219_list = filter ((== 5) . a007953) [0..] -- Reinhard Zumkeller, Jul 17 2014
-
Magma
[n: n in [1..3010] | &+Intseq(n) eq 5 ]; // Vincenzo Librandi, Mar 07 2013
-
Mathematica
Select[Range[10^4], Total[IntegerDigits[#]] == 5 &] (* Vincenzo Librandi, Mar 07 2013 *) Union[Flatten[Table[FromDigits /@ Permutations[PadRight[s, 9]], {s, IntegerPartitions[5]}]]] (* T. D. Noe, Mar 08 2013 *)
-
PARI
isok(n) = sumdigits(n) == 5; \\ Michel Marcus, Dec 28 2015
-
Python
from sympy.utilities.iterables import multiset_permutations def auptodigs(maxdigits): alst = [5] for d in range(2, maxdigits+1): fulldigset = list("0"*(d-1) + "1111122345") for firstdig in "12345": target_sum, restdigset = 5-int(firstdig), fulldigset[:] restdigset.remove(firstdig) for p in multiset_permutations(restdigset, d-1): if sum(map(int, p)) == target_sum: alst.append(int(firstdig+"".join(p))) if int(p[0]) == target_sum: break return alst print(auptodigs(4)) # Michael S. Branicky, May 14 2021
Extensions
Offset changed from Bruno Berselli, Mar 07 2013
Comments