Integer solutions to linear equation – Triangle with set perimeter

976 Views Asked by At

We have a triangle with the sides a, b and c where:

       / \ 
      /    \
  a  /       \   b
    /          \
   /             \
  /________________\

         c

$\ P = a+b+c$

$\ a+b > c$ else it's not a triangle

$\ a,b,c < P$ no side can be negative

P is known and I'm trying to find all integer solutions of (a,b,c).

By plotting $\ c = P - a - b$ we get a plane where a triangle shows all positive solutions. The solutions where $\ a+b > c$ valid is the the bottom part of this triangle. More I don't know.


EDIT

I'm looking for all solutions, not only the number of solutions. And if $\ P=12 $ I think (3,4,5) and (4,3,5) should be treated like different solutions.


Edit 2

I made an algorithm with C. With help of solutions for a range of vaules for P (See picture) I came up with the following rules:

(note: calling the sides x, y and z now, and now I treat (3,4,5) to be equal with (5,3,4))

Z will vary from (1) to (2)

(1) $Z_0=floor(P/2)$

(2) $Z_m=ceil(P/3)$

For a certain Z will X vary from (3) to (4)

(3) $X_0=Z$

(4) $X_m=floor((P-Z)/2)$

1

There are 1 best solutions below

2
On BEST ANSWER

Are you trying to find all the integer solutions, or will you settle for the number of integer solutions? The latter is given at this link.

EDIT: I'll indicate a systematic way to list all the solutions for $P=101$, and leave it to you to code it:

50 50 1; 50 1 50; 1 50 50.

50 49 2; 50 2 49; 49 50 2; 49 2 50; 2 50 49; 2 49 50.

50 48 3; etc.

.

.

.

49 49 3; 49 3 49; 3 49 49.

49 48 4; 49 4 48; 48 49 4; 48 4 49; 4 49 48; 4 48 49.

.

.

.

34 34 33; 34 33 34; 33 34 34.