human
Count of K length subsequence whose product is even | Function to calculate nCr.
Returns factorial of n.
Function for finding number of K length subsequences whose product is even number.
Counting odd numbers in the array.
Driver code"
Solution in Python:
 ... Can you provide a code to count of K length subsequence whose product is even and the other steps required?
assistant
#Here is code to count of K length subsequence whose product is even and the other steps required.
 def nCr ( n , r ) :
	if ( r > n ) :
		return 0
	return fact ( n ) // ( fact ( r ) * fact ( n - r ) )
def fact ( n ) :
	res = 1
	for i in range ( 2 , n + 1 ) :
		res = res * i
	return res
def countSubsequences ( arr , n , k ) :
	countOdd = 0
	for i in range ( n ) :
		if ( arr [ i ] & 1 ) :
			countOdd += 1 ;
	ans = nCr ( n , k ) - nCr ( countOdd , k ) ;
	return ans
arr = [ 2 , 4 ]
K = 1
N = len ( arr )
print ( countSubsequences ( arr , N , K ) )