text: Count of ways to split N into Triplets forming a Triangle | Function to return the required number of ways ; Check if a , b and c can form a triangle ; Return number of ways ; Driver Code
code: function Numberofways ( n ) { var count = 0 ; for ( var a = 1 ; a < n ; a ++ ) { for ( var b = 1 ; b < n ; b ++ ) { var c = n - ( a + b ) ; if ( a + b > c && a + c > b && b + c > a ) { count ++ ; } } } return count ; } var n = 15 ; document . write ( Numberofways ( n ) ) ;