How many ordered 6-tuplets of positive integers ( a 1 , a 2 , a 3 , a 4 , a 5 , a 6 ) satisfies a 1 + 2 a 2 + 3 a 3 + 4 a 4 + 5 a 5 + 6 a 6 = 6 0 ? Bonus: Can you generalize this?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Is it possible to apply the idea of Generating Functions, or does it make it more complicated ?
Log in to reply
The generating function of the sequence ( B k ( n ) ) n ≥ 0 is the function n = 0 ∑ ∞ B k ( n ) x n = r = 1 ∏ k 1 − x r 1 which is not that easy to expand for general k .
What's the difference between nonnegative and positive here?
According to your equation, A 2(3) == 0. But A 2(3) is actually equal to 1. The solution to a 1 + 2*a 2 = 3 is clearly: [1, 1].
Log in to reply
No. My formula says that A 2 ( 3 ) = B 2 ( 0 ) , which is 1 .
Log in to reply
You're talking about the matematica code or the formula? In the matematica it may be right, but in the formula I don't think so.
Log in to reply
@Asdasd Asdasd – My formula relates the As to the Bs, and the code calculates the Bs. Both are correct.
Below you will find my python and C++ solutions. In both cases I use recursion and caching of the solutions of the sub problems. The recursion is based on the following observation. For n , t ∈ N let S n , t be the number of positive solutions of the equation a 1 + 2 a 2 + 3 a 3 + … + n a n = t . Note that for n , t ∈ N , n > 1
The C++ solution is a bit tricky. The computation is done at the compile time. The solutions of the sub-problems are cached, because each template is generated only once. The C++ version requires C++17.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
The k used to define the upper bound of the summation is defined by each iteration of the summation itself? Is that right?
Log in to reply
This is my mistake, I have already corrected it. The summation bound should be ⌊ n t ⌋ . The idea is to sum over all of the values k ≥ 1 for which t − k n > 0 (or in other words: consider all terms S n − 1 , t − k n , which make sense).
Problem Loading...
Note Loading...
Set Loading...
If A k ( n ) is the number of k -tuples of positive integers ( a 1 , a 2 , . . . , a k ) such that a 1 + 2 a 2 + ⋯ + k a k = n , and if B k ( n ) is the number of k -tuples of nonnegative integers ( b 1 , b 2 , . . . , b k ) such that b 1 + 2 b 2 + ⋯ + k b k = n , then we see that A k ( n ) = { B k ( n − 2 1 k ( k + 1 ) ) 0 n ≥ 2 1 k ( k + 1 ) n < 2 1 k ( k + 1 ) (comparing the k -tuples a 1 , a 2 , . . . , a k and b 1 , b 2 , . . . , b k , where a j = b j + 1 for 1 ≤ j ≤ k ). The Mathematica code
calculates A 6 ( 6 0 ) = B 6 ( 3 9 ) = 3 3 3 1 .