Given three integers is it possible to determine if a triangle can be built with them?

481 Views Asked by At

I'm not good at geometry, but I'm trying to practice programming, and I'm asked to write a program that accepts three integers, and returns true or false depending if a triangle can be built using those values. I'm not asking for code or anything. I just want to know if there is any formula that could help me.

3

There are 3 best solutions below

0
On BEST ANSWER

Let $$a,b,c$$ the given numbers, then it must be $$a+b>c,a+c>b,b+c>a$$

0
On

Presumably you mean a triangle with those numbers as edge lengths. So the numbers must be positive, and the sum of any two must be greater than the third.

1
On

Similar to the other answers your numbers should satisfy triangle inequality. You can summarize it as $$\hbox{There is a triangle with lengths }a,b,c \hbox{ iff }\frac{a+b+c}{2}> \max(a,b,c)$$.