Split a number into 3 smaller numbers that form a triangle Given a positive integer L (1 <= L < 10000), how many possible solutions to split L into 3 smaller positive integer a, b, c
Such that: 


*

*a + b + c = L   

*a, b, c form a valid triangle


Note: The problem ask for the number of possible solutions 
A valid triangle (a, b, c) must meet these conditions:  

a, b, c > 0 && a + b > c && a + c > b && b + c > a

 A: Let 
 a >= b >= c

We've got two conditions: 
 a + b + c = L
 a < (b + c)    /* since {a, b, c} is a valid triangle */ 

So we can conclude, that the maximum side a should be
 L/3 <= a < L/2

and b, c are any numbers in (0..L/2) range (both limits excluded) such that a + b + c = L. An easy example is a = b = c = L/3
Edit: since a should be taken to be within the [L/3..L/2) range, there're infinitely many ways to do this (providing that L > 0).
Edit 2: The number of different triangles which have integer side lengths and perimeter L is
[L * L / 48]              for even L
[(L + 3) * (L + 3) / 48]  for odd L

[...] stands for inter part (floor)

see http://mathworld.wolfram.com/IntegerTriangle.html for details
implementation (C#):
   int count = (L % 2 == 0 ? L * L : (L + 3) * (L + 3)) / 48;

A: I think you need to be more specific. Do you mean find a possible solution or find number of possible triangles. If it's just one solution and I'm assuming a,b and c can only be positive integers, One solution if L >= 3 is a = 1, b =1, c= L - 2. If you want to find the number of possible solutions, then I think this is a recursive problem. Number of ways of dividing a number into three parts is the same as number of ways to divide it into two parts and divide one of the parts into two parts. Now the problem is writing a number as a sum of two others. For that we use basic maths. The solutions for a number n is:
n = 1 + (n-1)
   = 2 + (n-2)
      .
      .
      .
Until (n-k) = n/2.
So now that we can divide a number into two parts, use the logic above to divide the number into two parts first then divide it into two other parts. Keep a counter for the number of solutions you arrive at.
Cheers.
