human
Find the count of subsequences where each element is divisible by K | Function to return the count of all valid subsequences.
To store the count of elements which are divisible by k.
If current element is divisible by k then increment the count.
Total ( 2 ^ n - 1 ) non - empty subsequences are possible with n element.
Driver code"
Solution in Python:
assistant
#Here is code to find the count of subsequences where each element is divisible by K and the other steps required.
 def countSubSeq ( arr , n , k ) :
	count = 0 ;
	for i in range ( n ) :
		if ( arr [ i ] % k == 0 ) :
			count += 1 ;
	return ( 2 ** count - 1 ) ;
if __name__ == " _ _ main _ _ " :
	arr = [ 1 , 2 , 3 , 6 ] ;
	n = len ( arr ) ;
	k = 3 ;
	print ( countSubSeq ( arr , n , k ) ) ;