English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

3 answers

Sounds like an application of permutations and combinations.
Let us call T(n,s) the number of numbers of n digits which have sum s.
Consider any arbitrary n-digit number with digits {d_i} where 1≤i≤n . (We assume leading zeros are allowed i.e. 00456 can count as a 5-digit number. Otherwise that makes life too difficult)
Then the task is to work out how many permutations exist such that Σ d_i = s

Clearly if sum s=0 => T(n,0) = 1 (all zeros)
if s=1 => T(n,1) = s (one '1' and other digits zeros)
if s=2 => T(n,2) = s + (s)(s-1)/2! (one '2' or else two '1's and rest zeros)
if s=3 => T(n,3) = s + 2(s)(s-1)/2! + (s)(s-1)(s-2)/3! (one '3'/a '2' and a '1'/ three '1's - and rest zeros)
T(n,3) = C(s,1) + 2C(s,2) + C(s,3)

if s=4 => T(n,4) = C(s,1) + 2C(s,2) + C(s,2) +3C(s,3) +C(s,4)
= C(s,1) + 3C(s,2) + 3C(s,3) + C(s,4)
(one '4'/ a '3' and a '1'/two '2's/a '2' and two '1's/ four '1's - and rest zeros. Beyond this point take that any unmentioned digits are zero.)

if s=5 =>
(one '5'/a '4' and a '1'/a '3' and a '2'/a '3' and two '1's/two '2's and a '1'/a '2' and three '1's/ five'1's)
T(n,5) = C(s,1) + 4C(s,2) + 2C(s,2) + 3C(s,3) + 3C(s,3) + 4C(s,4) + C(s,5)
T(n,5) = C(s,1) + 6C(s,2) + 6C(s,3) + 4C(s,4) + C(s,5)

if s=6 =>
(one '6'/a '5' and a '1'/a '4' and a '2'/a '4' and two '1's/two '3's/
a '3', a '2' and a '1'/ a '3' and three '1's/three '2's/ two '2's and two '1's/a '2' and four '1's/ six '1's)
T(n,6) = C(s,1) + 2C(s,2) + 2C(s,2) + 3C(s,3) + 2C(s,2) + 3!C(s,3) + 4C(s,4) + C(s,3) + 2*2C(s,4) + 5C(s,5) + C(s,6)

Inductively it is looking like we get T(n,s) somehow from T(n, 0 up to s-1), involving some weighted summation of Pascal coefficients C(n,m).

Let us write the expressions as a vector of coefficients of C(s,m) in the summation, reading from right-to-left such that the rightmost is the coefficient of C(s,1) e.g.
T(n,5) = <1,4,6,6,1> stands for
T(n,5) = C(s,1) + 6C(s,2) + 6C(s,3) + 4C(s,4) + C(s,5)
Thus:
T(n,4) = <1,3,3,1>
T(n,3) = <1,2,1>
T(n,2) = <1,1>
and:
T(n,6) = <1,5,2*2 + 4,1 + 3! +3, 2+2+2,1>
T(n,6) = <1,5,8,10,6,1>

You can see the pattern but it ain't trivial at all! (This involves the theory of 'generating functions', see e.g. the references below.)
So call the summation pattern:
T(n,s) = Σ b(n,s,j) C(s,j)
where the coefficients b(n,s,j) are the coefficients from our vector above;and we understand the extended definition of Pascal's coefficients: C(s,j)≡0 for j>s

The problem can be broken down into the following:
a) how many different (ordered) ways to generate the sum s from combinations of the integers {1,..,9} using up to n non-zero digits
e.g. 5 = 5, 4+1, 3+2, 3+1+1, 2+1+1+1, 2+2+1, 1+1+1+1+1 . This step is probably recursive.
b) for each of the options in a) how many different PERMUTATIONS of the s digits correspond to that option.

In particular I recommend this outstanding problem-and-solution bible: "Challenging Mathematical Problems With Elementary Solutions (Vol 1)" by Yaglom and Yaglom.
Sections II: Representation of numbers as sums and products
Section V: Problems on the binomial coefficients.
It has very carefully chosen graduated-difficulty, and the hard problems generally build on the easier ones.
It is an outstandingly fun and creative book in an area which is usually mindblowingly boring.

2007-11-23 19:13:30 · answer #1 · answered by smci 7 · 3 0

This is tricky since I am assuming you mean base 10, in which the maximum possible digit is 9. If we just had to partition n into s nonnegative numbers the number of ways to do this would be:

(n+s-1)!/[(n-1)!s!]

If we insisted the first digit was nonzero, the number of ways would be:

(n+s-2)!/[(n-1)!(s-1)!]

However if each digit must be at most 9, it gets quite tricky.

2007-11-23 19:21:30 · answer #2 · answered by Phineas Bogg 6 · 2 0

An infinite number for s=n, for example, since this would include all of the repunits:

1
11
111
1111
11111
etc

2007-11-23 19:14:23 · answer #3 · answered by Anonymous · 1 4

fedest.com, questions and answers