Count of possible subarrays and subsequences using given length of Array | Function to count the subarray for the given array ; Function to count the subsequence for the given array length ; Driver Code
function countSubarray ( n ) { return ( ( n ) * ( n + 1 ) ) / 2 ; } function countSubsequence ( n ) { return Math . pow ( 2 , n ) ; } let n = 5 ; document . write ( ( countSubarray ( n ) ) + " " ) ; document . write ( ( countSubsequence ( n ) ) + " " ) ;