OFFSET
1,2
COMMENTS
Number of n-digit numbers with digit sum n.
Middle diagonal of A213651. - Miquel Cerda, Aug 11 2017
LINKS
Robert Israel, Table of n, a(n) for n = 1..1100
Ji Young Choi, Digit Sums Generalizing Binomial Coefficients, J. Int. Seq., Vol. 22 (2019), Article 19.8.3.
FORMULA
Equals binomial(2n-2, n-1) for n <= 9, by the stars and bars argument. [To get such a number take n boxes in which the leftmost box contains a 1 and the rest are empty. Distribute the remaining n-1 1's into the n boxes subject to the constraint that no box contains more than 9 1's. This can be done in binomial(2n-2, n-1) ways for n <= 9.]
Coefficient of x^n in T^n - T^(n-1), where T = 1+x+...+x^9. - Robert Israel, Apr 06 2016
EXAMPLE
a(3) = 6 as there are six three-digit numbers with digit sum 3: 102, 111, 120, 201, 210, 300.
a(10) = binomial(18,9)-1; a(11) = binomial(20,10)-21; a(12) = binomial(22,11)-210.
MAPLE
T:= add(x^i, i=0..9):
seq(coeff(T^n - T^(n-1), x, n), n=1..25); # Robert Israel, Apr 06 2016
MATHEMATICA
Do[c = 0; k = 10^n; l = 10^(n + 1) - 1; While[k < l, If[ Plus @@ IntegerDigits[k] == n + 1, c++ ]; k++ ]; Print[c], {n, 0, 7}]
PROG
(PARI) a(n)=local(y=(x^10-1)/(x-1)); if(n<1, 0, polcoeff((y-1)*y^(n-1), n))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Amarnath Murthy, Jun 18 2002
EXTENSIONS
Edited by N. J. A. Sloane and Robert G. Wilson v, Jun 20 2002
More terms from Vladeta Jovovic, Jun 21 2002
More terms from John W. Layman, Jun 22 2002
STATUS
approved