Count of possible subarrays and subsequences using given length of Array | C # implementation to count the subarray and subsequence of given length of the array ; Function to count the subarray for the given array ; Function to count the subsequence for the given array length ; Driver Code
using System ; class GFG { static int countSubarray ( int n ) { return ( ( n ) * ( n + 1 ) ) / 2 ; } static int countSubsequence ( int n ) { return ( int ) Math . Pow ( 2 , n ) ; } public static void Main ( String [ ] args ) { int n = 5 ; Console . Write ( ( countSubarray ( n ) ) + " STRNEWLINE " ) ; Console . Write ( ( countSubsequence ( n ) ) + " STRNEWLINE " ) ; } }