human
Give me a code to count of all subsequence whose product is a Composite number and the other steps required given the following:
Count of all subsequence whose product is a Composite number | Function to check whether a number is prime or not.
Function to find number of subsequences whose product is a composite number.
Find total non empty subsequence.
Find count of prime number and ones.
Calculate the non empty one subsequence.
Find count of composite subsequence.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to count of all subsequence whose product is a Composite number and the other steps required.
 def isPrime ( n ) :
	if ( n <= 1 ) :
		return False ;
	for i in range ( 2 , n ) :
		if ( n % i == 0 ) :
			return False ;
	return True ;
def countSubsequences ( arr , n ) :
	totalSubsequence = ( int ) ( pow ( 2 , n ) - 1 ) ;
	countPrime = 0 ;
	countOnes = 0 ;
	for i in range ( n ) :
		if ( arr [ i ] == 1 ) :
			countOnes += 1 ;
		elif ( isPrime ( arr [ i ] ) ) :
			countPrime += 1 ;
	compositeSubsequence = 0 ;
	onesSequence = ( int ) ( pow ( 2 , countOnes ) - 1 ) ;
	compositeSubsequence = ( totalSubsequence - countPrime - onesSequence - onesSequence * countPrime ) ;
	return compositeSubsequence ;
if __name__ == ' _ _ main _ _ ' :
	arr = [ 2 , 1 , 2 ] ;
	n = len ( arr ) ;
	print ( countSubsequences ( arr , n ) ) ;