Count of triplets of numbers 1 to N such that middle element is always largest | Function to find number of triplets for given number N such that middle element is always greater than left and right side element . ; Check if arrangement is possible or not ; Else return total ways ; Driver Code
function findArrangement ( N ) { if ( N < 3 ) return 0 ; return ( ( N ) * ( N - 1 ) * ( N - 2 ) ) / 3 ; } let N = 10 ; document . write ( findArrangement ( N ) ) ;