My bad.. it should be this:
  num_triangles = 0
      for i:2 to N-2
        for j:i+1 to N-1
           num_triangles += i+j<=N ? i-1:N-j

This gives values in increasing order such that c>b>a (c,b,a being lengths 
of sides of the triangle) and sum of any two sides is greater than the 
third.

Consider : 1,2,3,4,5,6
Possible side combinations are:
2,3,4
2,4,5
2,5,6
3,4,5
3,4,6
3,5,6
4,5,6

I hope i am not wrong.

On Wednesday, 13 June 2012 22:18:01 UTC+5:30, payel roy wrote:
>
>
> Let's say there are N sides are given. Length of them are like 
> 1,2,3,4,5,....N. 
>
> How do you determine how many tri-angles can be made out of these N sides? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/ejR_WEuHquEJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to