Triangles

Integer Triangles and Counting Those With a Given Perimeter

Count the triangles with whole-number sides and a fixed perimeter, using a table, a formula and a short proof.

Key takeaways

  • Three whole numbers a ≤ b ≤ c form a triangle exactly when a + b is greater than c.
  • The count for perimeter n is the nearest integer to n²/48 for even n and (n + 3)²/48 for odd n.
  • An even perimeter n has the same count as the odd perimeter n − 3.
  • Counting even-perimeter triangles is the same as splitting n/2 into three positive whole parts.

An integer triangle has three whole-number side lengths. The number of different ones with perimeter n has a surprisingly short answer: take n²/48 if n is even, or (n + 3)²/48 if n is odd, and round to the nearest whole number.

For example, there are 3 triangles with perimeter 12 and 7 with perimeter 15. Yes, the larger perimeter gives more, but the count does not rise steadily: perimeter 16 has only 5. This article builds the table by hand, explains the zigzag and proves the formula.

The rules of the count

Two triangles count as the same if they have the same three side lengths in any order. So you may always list sides as a ≤ b ≤ c. Flat triangles do not count, so the condition is a + b > c, strictly.

With the sides sorted, that single inequality is enough, as explained in which three lengths can form a triangle. Since a + b + c = n, it says that c is less than n/2. And c, being largest, is at least n/3.

That gives a procedure. Run c from the smallest allowed value to the largest, and for each, list the pairs a ≤ b ≤ c with a + b = n − c.

Listing perimeter 15

Here c runs from 5 to 7.

Largest side c a + b Triangles (a, b, c) How many
7 8 (1,7,7), (2,6,7), (3,5,7), (4,4,7) 4
6 9 (3,6,6), (4,5,6) 2
5 10 (5,5,5) 1

The total is 7. The formula gives (15 + 3)²/48 = 324/48 = 6.75, which rounds to 7.

A systematic order like this is what prevents double counting. If you write (6, 4, 5) and (4, 5, 6) separately, you have counted one triangle twice.

A second example, with an even perimeter

For perimeter 16, the largest side c is at least 16/3, so at least 6, and less than 8.

Largest side c a + b Triangles (a, b, c) How many
7 9 (2,7,7), (3,6,7), (4,5,7) 3
6 10 (4,6,6), (5,5,6) 2

That makes 5 in all, and 256/48 is about 5.33. Notice that (1,7,8) is missing because its largest side would be 8, which is half the perimeter and gives a flat figure.

You can picture the count geometrically. Plot each sorted triple by its values of a and b. The conditions b ≤ c and a + b > c carve out a small triangular region of grid points. As n grows, that region grows in both directions, so the number of points grows roughly like n². That explains the shape of the formula before any algebra.

The table and its zigzag

n 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
count 1 0 1 1 2 1 3 2 4 3 5 4 7 5 8 7

The sequence is often named after Alcuin of York, an eighth-century scholar associated with a collection of puzzles that includes a related problem about sharing casks.

Odd perimeters run ahead of their even neighbors. The reason is parity. When n is even, the strict inequality forces a + b to exceed c by at least 2, because a + b − c = n − 2c is even. That extra unit of slack is wasted, and fewer triples qualify.

The shift by three

Look at the table: the count for 12 equals the count for 9, and the count for 18 equals the count for 15. This holds for every even n.

Take a triangle with odd perimeter n − 3 and add 1 to each side. The perimeter becomes n. The quantity a + b − c goes up by 1, so it stays positive.

Now reverse it. Take a triangle with even perimeter n and subtract 1 from each side. We showed that a + b − c is at least 2, so after subtracting it is still at least 1. The sides stay positive too: with b ≤ c, the value a + b − c is at most a, so the shortest side a is at least 2. The two sets of triangles are matched one for one.

Why one formula covers all perimeters
1 Odd to even Add 1 to every side of an odd-perimeter triangle 2 Even to parts Set x = k − a, y = k − b, z = k − c, with k = n/2 3 Count splits Count x + y + z = k in positive whole numbers 4 Round The answer is the nearest integer to k²/12 Odd to even Add 1 to every side of an odd-perimeter triangle 1 Even to parts Set x = k − a, y = k − b, z = k − c, with k = n/2 2 Count splits Count x + y + z = k in positive whole numbers 3 Round The answer is the nearest integer to k²/12 4

Turning triangles into splits

Let n = 2k. Define x = k − a, y = k − b and z = k − c. The triangle condition says every side is less than k, so x, y and z are positive whole numbers. Their sum is 3k − 2k = k.

Going back, any positive x, y, z with sum k give sides a = y + z, b = z + x and c = x + y, which always form a triangle. These three numbers are the tangent lengths from the corners to the incircle.

So the problem is now: in how many ways can k be written as a sum of three positive whole numbers, ignoring order? For k = 6 the splits are 4+1+1, 3+2+1 and 2+2+2. That is 3, matching perimeter 12.

Proving the rounding formula

First count ordered solutions of x + y + z = k. Picture k dots in a row and choose 2 of the k − 1 gaps as dividers. There are (k − 1)(k − 2)/2 ways.

An unordered split with three different parts appears 6 times in that list. One with exactly two equal parts appears 3 times, and the all-equal split appears once. To make every split count 6 times, add corrections:

  • Add the solutions with x = y, those with y = z and those with z = x. Each of the three conditions has as many solutions as there are positive x with 2x < k.
  • Add 2 more if k is divisible by 3, to top up the solution with all parts equal.

The number of x with 2x < k is (k − 2)/2 for even k and (k − 1)/2 for odd k. Let e be 1 when 3 divides k and 0 otherwise. Adding and dividing by 6:

k even:  count = (k² − 4 + 4e)/12
k odd:   count = (k² − 1 + 4e)/12

In every case the count differs from k²/12 by at most one third, which is less than one half. So rounding k²/12 gives it exactly. Since k = n/2, this is n²/48, and the shift by three handles odd n.

The formula checked case by case

Here is the ordered count at work for k = 8, which corresponds to perimeter 16.

ordered splits of 8:        7 × 6 / 2 = 21
solutions with x = y:       x = 1, 2, 3, giving 3
same for y = z and z = x:   3 + 3 more
3 does not divide 8:        no extra
total = 21 + 9 = 30, and 30 / 6 = 5

Five matches the list above, and 64/12 is about 5.33.

Now k = 9, perimeter 18. There are 28 ordered splits. Solutions with x = y have x from 1 to 4, so the three conditions give 12. Since 3 divides 9, add 2. The total is 42, and dividing by 6 gives 7. Rounding 81/12 = 6.75 also gives 7.

This style of correction, counting everything with order and then averaging over the six ways of rearranging three items, works for many counting questions with symmetry.

Special kinds inside the count

Isosceles triangles, including equilateral ones, are easy to count: choose the two equal sides m and the third side n − 2m, which must satisfy 0 < n − 2m < 2m. So m lies strictly between n/4 and n/2. For n = 15, m can be 4, 5, 6 or 7, giving four isosceles triangles.

Equilateral triangles exist exactly when 3 divides n, and then there is one. Scalene triangles are what remains: for n = 15 there are 7 − 4 = 3, namely (2,6,7), (3,5,7) and (4,5,6).

Right triangles with whole sides are much rarer. Among perimeters up to 30 they occur at 12 for (3,4,5), 24 for (6,8,10) and 30 for (5,12,13).

Which triangle is largest?

Among the integer triangles with a given perimeter, the one closest to equilateral has the greatest area. For perimeter 15 that is (5,5,5), with area about 10.8. The slimmest, (1,7,7), has area about 3.5.

When 3 does not divide n, the winner uses sides that differ by at most 1, such as (5,5,6) for perimeter 16. The reasoning behind this is in the largest triangle for a fixed perimeter.

Shapes also repeat across perimeters. The triangle (2,3,4) at perimeter 9 reappears as (4,6,8) at perimeter 18. If you want to count only shapes that are not scaled copies of smaller ones, keep the triples whose three sides have no common factor above 1. For perimeter 12, that removes (4,4,4), leaving (2,5,5) and (3,4,5).

Harder questions about integer triangles

Which integer triangles have integer area? These are called Heronian triangles. The 13-14-15 triangle, with area 84, is a well-known example that has no right angle, though it splits into two right triangles with whole sides along one height.

An equilateral integer triangle never has integer area, because its area involves the irrational number √3. A related fact for dot paper is explored in which regular polygons fit on a grid.

You can also count by largest side instead of perimeter. With largest side c, the number of triangles is exactly (c + 1)²/4 rounded down. For c = 7 that gives 16.

Common mistakes

  • Allowing a + b = c, which produces a segment, not a triangle.
  • Counting reorderings or mirror images as different triangles.
  • Applying the even formula to an odd perimeter.
  • Assuming the count always rises with n. Compare n = 15 and n = 16.

Try it

How many integer triangles have perimeter 30? Since 30 is even, compute 900/48 = 18.75 and round to 19. Then give the count for perimeter 27 without any new calculation, using the shift by three. It is also 19.

As a final check, list perimeter 11 by hand. The largest side can be 4 or 5. You should find (3,4,4) with largest side 4, and (1,5,5), (2,4,5) and (3,3,5) with largest side 5. That makes 4 triangles, and (11 + 3)²/48 = 196/48, about 4.08, agrees.

Written for 4Geometry with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 57 articles in Triangles →

Latest news on this topic