Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

How would I go about calculating the total number of possible triangles where the perimeter is given, and all sides are integers?

Exempli gratia:

  • a + b + c = 15
  • d + e + f = 16
  • x + y + z = 100
share|improve this question
    
I don't remember how to do this problem, but the final form of the (generating function of the) solution turns out to be extremely nice. Is this up to relabeling of the sides or not? –  Qiaochu Yuan Feb 17 '11 at 9:49

4 Answers 4

up vote 2 down vote accepted

It rather depends on whether you regard 7,5,4 as the same triangle as 5,7,4 (edges in a different order), and whether you allow the triangles 8,8,0 (with a zero edge) or 8,5,3 (with a zero area). Let's suppose not in what follows.

So start with the longest side: it cannot be longer than or equal to half the perimeter, but it must be at least a third of the perimeter. So that gives you a limited set of values. Now consider the middle sized side: it must be at least half the difference between the perimeter and the longest side, but cannot be longer than the longest side. Together these will tell you the shortest side. So just add up the number of different shortest sides for each possible longest side.

For example with a perimeter of 15, the longest side must be 5, 6 or 7. If it is 5 then the middle side can be 5; if it is 6 then the middle side can be 5 or 6; if it is 7 then the middle side can be 4, 5, 6 or 7. Adding those up gives 1+2+4 = 7.

Similar results can be found for other small perimeters. It is also possible to derive a general formula which has the curious property that $a(2n-3) = a(2n)$, or in other words, starting with a triangle with an odd perimeter, we can find a related triangle with a perimeter 3 more just by adding 1 to each side.

share|improve this answer
    
From what I gather, the problem does not allow for zero edges and 7,5,4 is considered the same as 5,7,4. Thanks! What I don't understand though, is how to tell whether the three integers fit together to form said triangle, i.e., how can I know whether 32,33,34 forms a real triangle or not? –  oKtosiTe Feb 17 '11 at 10:37
2  
If all three sides are positive and the sum of any two sides is greater than the third then you have a real positive area triangle. –  Henry Feb 17 '11 at 12:26
    
Now that I think of it some more, that last question was just silly, thanks though! @Henry –  oKtosiTe Feb 17 '11 at 14:22

This is given in A005044. The generating function is $\frac{x^3}{(1-x^2)(1-x^3)(1-x^4)}$ Some other formulas and references are given as well

share|improve this answer

Let ${\cal S}_p$ be the set of ordered triples $(a,b,c) \in \mathbb{N}^3$ such that $c \ge b \ge a \ge 1$, $a+b+c=p$, and $a+b > c$ (the triangle inequality). For instance, ${\cal S}_3 = \{ (1,1,1) \}$ and ${\cal S}_4 = \{ \}$. Each triple in ${\cal S}_{p-2}$ gives rise to a triple in ${\cal S}_{p}$ under the transformation $(a,b,c)\rightarrow(a,b+1,c+1)$, and all triples in ${\cal S}_{p}$ are produced by this transformation except for those of the form $(a,a,c)$. These latter triples can be counted directly: there is one for each value of $a$ for which $3a \le p < 4a$, and so there are exactly $I_p = \lfloor{p/3}\rfloor - \lceil{(p+1)/4}\rceil + 1$ of them. So we have the recurrence $S_p = S_{p-2} + I_p$ for the values of $S_p = |{\cal S}_p|$, with initial conditions $S_0=S_1=0$. The addend has period $12$, and takes on values $$ I_{12k+(0,1,2,...,11)} = k + (0,0,0,1,0,0,1,1,0,1,1,1). $$ We then have $S_{12(k+1)} = S_{12k} + 6k + 3$ and $S_{12(k+1)+1} = S_{12k+1} + 6k + 5$, leading to quadratic solutions $S_{12k} = 3k^2$ and $S_{12k+1} = 3k^2 + 2k$. The full set of solutions is $$ \begin{eqnarray} S_{12k} &=& 3k^2 \\ S_{12k+1} &=& 3k^2 + 2k \\ S_{12k+2} &=& 3k^2 + k \\ S_{12k+3} &=& 3k^2 + 3k + 1\\ S_{12k+4} &=& 3k^2 + 2k \\ S_{12k+5} &=& 3k^2 + 4k + 1 \\ S_{12k+6} &=& 3k^2 + 3k + 1 \\ S_{12k+7} &=& 3k^2 + 5k + 2 \\ S_{12k+8} &=& 3k^2 + 4k + 1 \\ S_{12k+9} &=& 3k^2 + 6k + 3 \\ S_{12k+10} &=& 3k^2 + 5k + 2 \\ S_{12k+11} &=& 3k^2 + 7k + 4. \end{eqnarray} $$ Note that, as noted elsewhere, for all odd $p$ we have $S_{p} = S_{p+3}$.

share|improve this answer

No of possible triangles $n$ having perimeter $p= p^2/48$ if $p$ is even.

share|improve this answer
2  
I would guess people are interested on how did you come up with the solution. –  rank Aug 22 at 8:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.