text: Count of ways to split N into Triplets forming a Triangle | Java Program to implement the above approach ; Function to return the required number of ways ; Check if a , b , c can form a triangle ; Return number of ways ; Driver Code
code: import java . io . * ; class GFG { static int Numberofways ( int n ) { int count = 0 ; for ( int a = 1 ; a < n ; a ++ ) { for ( int b = 0 ; b < n ; b ++ ) { int c = n - ( a + b ) ; if ( a + b > c && a + c > b && b + c > a ) { count ++ ; } } } return count ; } public static void main ( String [ ] args ) { int n = 15 ; System . out . println ( Numberofways ( n ) ) ; } }