Ask Your Question

Revision history [back]

@Nathann's answer explains that with your code, Sage is not calculating the number but enumerating all submultisets, which in this case just takes too long.

For your particular counting problem, you can use compositions (also known as ordered partitions). You can iterate through compositions of 14 with maximum part 2, (there are 610 of them), and count each of them with an appropriate weight (some binomial coefficient) to account for the number of ways to choose which numbers the parts refer to.

sage: C = Compositions(14,outer=[2]*53) 
sage: C.cardinality()
610
sage: sum(binomial(53,len(c)) for c in C)
48204860086530