Crazy is that !

If x , y , z , a , x,y,z,a, and b b are non-negative integers, how many distinct 5-tuples ( x , y , z , a , b ) (x,y,z,a,b) that satisfy x + y + z + a + b = 15 x+y+z+a+b =15 exist?


The answer is 3876.

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.

2 solutions

Sujoy Roy
Nov 25, 2014

Total ways = 15 + 5 1 C 5 1 = 19 C 4 = 3876 =^{15+5-1}C_{5-1}=^{19}C_{4}=\boxed{3876}

how and why? please explain

Mardokay Mosazghi - 6 years, 6 months ago

Log in to reply

See Stars and bars .

Calvin Lin Staff - 6 years, 5 months ago

It is a formula. Given the equation:

x 1 + x 2 + + x n = r x_1 + x_2 + \ldots + x_n = r

There are ( n + r 1 r ) {{n + r - 1} \choose {r}} different ways for the sum to be satisfied.

Sharky Kesa - 6 years, 6 months ago

Log in to reply

Provided that x 1 , x 2 , . . . x n 0 {x}_{1}, {x}_{2},...{x}_{n} \geq 0 . And yes, nothing more special in it, it is just found by assuming that we have r balls which we have to 'distribute' in n boxes. And the no. of ways for the same is given by that formula which can be found easily.

Kartik Sharma - 6 years, 6 months ago

thanks for clarification.

Mardokay Mosazghi - 6 years, 6 months ago
Brock Brown
Dec 27, 2014

Solved with nested for loops:

1
2
3
4
5
6
7
8
9
count = 0
for a in xrange(16):
    for b in xrange(16):
        for c in xrange(16):
            for d in xrange(16):
                for e in xrange(16):
                    if a+b+c+d+e == 15:
                        count += 1
print count

Here's a slightly shorter solution:

1
2
3
4
5
6
from itertools import product
count = 0
for a,b,c,d,e in product(xrange(16), repeat = 5):
    if a+b+c+d+e == 15:
        count += 1
print count

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...