human
Sum of all the Composite Numbers from Odd indices of the given array | Function to print the sum of all composite numbers in the array.
Iterate for odd indices in the array.
Check if the number is composite then add it to sum.
return the sum.
Function to check for composite numbers.
Check if the factors are greater than 2.
Check if the number is composite or not.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to sum of all the Composite Numbers from Odd indices of the given array and the other steps required.
 def odd_indices ( arr ) :
	sum = 0
	for k in range ( 0 , len ( arr ) , 2 ) :
		check = composite ( arr [ k ] )
		sum += arr [ k ] if check == 1 else 0
	print ( sum )
def composite ( n ) :
	flag = 0
	c = 0
	for j in range ( 1 , n + 1 ) :
		if ( n % j == 0 ) :
			c += 1
	if ( c >= 3 ) :
		flag = 1
	return flag
if __name__ == " _ _ main _ _ " :
	arr = [ 13 , 5 , 8 , 16 , 25 ]
	odd_indices ( arr )