Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

For k colors with n marbles each, I find it to be:

May require some modification when number of marbles are different.

*Last edited by gAr (2013-04-27 22:53:23)*

"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,224

Hi gAr;

That is a nice one, it will come in handy.

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Hi,

Got a recursion to work!

Here's a sage code:

```
A = 10
B = 10
C = 10
D = 10
def f(a,b,c,d):
if (A-a == 2 or B-b == 2 or C-c == 2 or D-d == 2):
return (A+B+C+D-(a+b+c+d))
return a/Integer(a+b+c+d)*f(a-1,b,c,d) + b/Integer(a+b+c+d)*f(a,b-1,c,d) + c/Integer(a+b+c+d)*f(a,b,c-1,d) + d/Integer(a+b+c+d)*f(a,b,c,d-1)
print f(A,B,C,D)
```

It returns : 30008/9139

"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,224

Hi gAr;

Yeparoo! Very good!

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Yeah, that looks much neater than the formula!

I think this will help in many problems involving probability..

"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,224

Hi;

Have you tried the formula in post#26 on this problem?

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Yes, and we must multiply that by 2, I forgot to include that.

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,224

I am not getting the correct answer then, when I multiply by 2 I get:

I am using n = 10 and k = 4.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Perhaps I made a mistake when translating my program to the formula? Or you took out n from the sum ?

Here's the code I used:

```
def ans(n,k):
summ = 0
for i in range(1,k+1):
pr = 1
for j in range(1,i):
pr *= (k-j)*n/Integer(4*n-j)
summ += (i)*(i+1)/2 * pr * (n-1)/Integer(4*n-i)
return 2*summ
```

ans(10,4) returns 30008/9139

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,224

Hi;

Why the Integer() command?

**In mathematics, you don't understand things. You just get used to them.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

It causes problem like flooring if it's not written..

In python, we need to convert it to float.

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,224

Hi;

There is a typo in the formula. In post #26 there is (k-i), in post #34, (k-j).

**In mathematics, you don't understand things. You just get used to them.**

Offline

**Pearl2013****Member**- Registered: 2013-04-27
- Posts: 6

Oop answer was wrong

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Hi bobbym,

Ah yes, sorry!

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,224

No problem! Thank you for the formula.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

You're welcome!

I think we can't write a formula like that when the number of marbles are different for different colors, since it involves permutation?

Anyway, I'll stop here, spent almost a day on this one!

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,224

Hi;

I will play with it a little in a bit. Right now there is a little bit of an administrative matter to watch for.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Okay..

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,224

Hi;

Looks like the worst is over. Now about that formula...

If we hold k = 4 and vary n then we come up with this:

for n = 2, 3, 4, ...

**In mathematics, you don't understand things. You just get used to them.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

That's a good one!

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,224

Oh yes and quite useless unless you have exactly 4 colors.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Anyway, we can easily extend the recursion if not the formula for any number of variables and experiment with the terms.

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,224

There are a lot of possibilities here.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Yes.

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 92,224

Hi;

I am going to get a little sleep. See you later.

**In mathematics, you don't understand things. You just get used to them.**

Offline