# Thread: Solving for a, b and c

1. ## Solving for a, b and c

Do you know of any algorithm that can solve (look for possible values) for a, b and c in the equation:

a + b + c = n

where a, b, c and n are integers and are greater than 0?

2. Hello, milkntea!

Do you know of any algorithm that can solve for $a, b, c$ in the equation:

. . $a + b + c \:=\: n$ . for $a,b,c,n \,\in\, I^+$
Here's a primitive approach . . .

Suppse $n = 7$ . . . We have 7 objects.

Place them in a row with a space between then: . $o\;\_\;o\;\_\;o\;\_\;o\;\_\;o\;\_\;o\;\_\;o$

Select two of the spaces and insert "dividers".

So that: . $o\;|\;o\;o\;o\;o\;|\;o\;o$ .represents $1+4+2$

. . .And: . $o\;o\;o\;|\;o\;o\;|\;o\;o$ .represents $3+2+2$

Hence, there are: . ${6\choose2} \,=\,15$ possible solutions.

I'll leave it to you to list them . . .
.

3. Originally Posted by Soroban
Hello, milkntea!

Here's a primitive approach . . .

Suppse $n = 7$ . . . We have 7 objects.

Place them in a row with a space between then: . $o\;\_\;o\;\_\;o\;\_\;o\;\_\;o\;\_\;o\;\_\;o$

Select two of the spaces and insert "dividers".

So that: . $o\;|\;o\;o\;o\;o\;|\;o\;o$ .represents $1+4+2$

. . .And: . $o\;o\;o\;|\;o\;o\;|\;o\;o$ .represents $3+2+2$

Hence, there are: . ${6\choose2} \,=\,15$ possible solutions.

I'll leave it to you to list them . . .
.
Thanks Soroban!

I am using this for a computer program that looks for

$a+b+c = 1000$

where:

$a^2 + b^2 = c^2$

I'll try it myself for now, I'll ask more questions later

Thanks again!

4. Originally Posted by milkntea
Thanks Soroban!

I am using this for a computer program that looks for

$a+b+c = 1000$

where:

$a^2 + b^2 = c^2$

I'll try it myself for now, I'll ask more questions later

Thanks again!
One thought:

What if I add another condition?

$(a>b>c)$