A052224 Numbers whose sum of digits is 10.
19, 28, 37, 46, 55, 64, 73, 82, 91, 109, 118, 127, 136, 145, 154, 163, 172, 181, 190, 208, 217, 226, 235, 244, 253, 262, 271, 280, 307, 316, 325, 334, 343, 352, 361, 370, 406, 415, 424, 433, 442, 451, 460, 505, 514, 523, 532, 541, 550, 604, 613, 622, 631, 640
Offset: 1
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..10000 (first 3921 terms from T. D. Noe)
Crossrefs
Programs
-
Haskell
a052224 n = a052224_list !! (n-1) a052224_list = filter ((== 10) . a007953) [0..] -- Reinhard Zumkeller, Jul 17 2014
-
Magma
[n: n in [1..1000] | &+Intseq(n) eq 10 ]; // Vincenzo Librandi, Mar 10 2013
-
Maple
sd := proc (n) options operator, arrow: add(convert(n, base, 10)[j], j = 1 .. nops(convert(n, base, 10))) end proc: a := proc (n) if sd(n) = 10 then n else end if end proc: seq(a(n), n = 1 .. 800); # Emeric Deutsch, Jan 16 2009
-
Mathematica
Union[Flatten[Table[FromDigits /@ Permutations[PadRight[s, 7]], {s, Rest[IntegerPartitions[10]]}]]] (* T. D. Noe, Mar 08 2013 *) Select[Range[1000], Total[IntegerDigits[#]] == 10 &] (* Vincenzo Librandi, Mar 10 2013 *)
-
PARI
isok(n) = sumdigits(n) == 10; \\ Michel Marcus, Dec 28 2015
-
PARI
\\ This algorithm needs a modified binomial. C(n, k)=if(n>=k, binomial(n, k), 0) \\ ways to roll s-q with q dice having sides 0 through n - 1. b(s, q, n)=if(s<=q*(n-1), s+=q; sum(i=0, q-1, (-1)^i*C(q, i)*C(s-1-n*i, q-1)), 0) \\ main algorithm; this program applies to all sequences of the form "Numbers whose sum of digits is m." a(n,{m=10}) = {my(q); q = 2; while(b(m, q, 10) < n, q++); q--; s = m; os = m; r=0; while(q, if(b(s, q, 10) < n, n-=b(s, q, 10); s--, r+=(os-s)*10^(q); os = s; q--)); r+= s; r} \\ David A. Corneth, Jun 05 2016
-
Python
from sympy.utilities.iterables import multiset_permutations def auptodigs(maxdigits, b=10, sod=10): # works for any base, sum-of-digits alst = [sod] if 0 <= sod < b else [] nzdigs = [i for i in range(1, b) if i <= sod] nzmultiset = [] for d in range(1, b): nzmultiset += [d]*(sod//d) for d in range(2, maxdigits + 1): fullmultiset = [0]*(d-1-(sod-1)//(b-1)) + nzmultiset for firstdig in nzdigs: target_sum, restmultiset = sod - int(firstdig), fullmultiset[:] restmultiset.remove(firstdig) for p in multiset_permutations(restmultiset, d-1): if sum(p) == target_sum: alst.append(int("".join(map(str, [firstdig]+p)), b)) if p[0] == target_sum: break return alst print(auptodigs(4)) # Michael S. Branicky, Sep 14 2021
-
Python
def A052224(N = 19): """Return a generator of the sequence of all integers >= N with the same digit sum as N.""" while True: yield N N = A228915(N) # skip to next larger integer with the same digit sum a = A052224(); [next(a) for in range(50)] # _M. F. Hasler, Mar 16 2022
Formula
a(n+1) = A228915(a(n)) for any n > 0. - Rémy Sigrist, Jul 10 2018
Extensions
Incorrect formula deleted by N. J. A. Sloane, Jan 15 2009
Extended by Emeric Deutsch, Jan 16 2009
Offset changed by Bruno Berselli, Mar 07 2013
Comments