# 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 $\displaystyle a, b, c$ in the equation:

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

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

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

Select two of the spaces and insert "dividers".

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

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

Hence, there are: .$\displaystyle {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 $\displaystyle n = 7$ . . . We have 7 objects.

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

Select two of the spaces and insert "dividers".

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

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

Hence, there are: .$\displaystyle {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

$\displaystyle a+b+c = 1000$

where:

$\displaystyle 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

$\displaystyle a+b+c = 1000$

where:

$\displaystyle 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?

$\displaystyle (a>b>c)$