human
Count array elements having modular inverse under given prime number P equal to itself | Function to get the count of elements that satisfy the given condition ..
Stores count of elements that satisfy the condition.
Traverse the given array ..
If square of current element is equal to 1.
Driver Code"
How can the above be solved in Python?
 ... What is a code to count array elements having modular inverse under given prime number P equal to itself and the other steps required?
assistant
#Here is code to count array elements having modular inverse under given prime number P equal to itself and the other steps required.
 def equvInverse ( arr , N , P ) :
	cntElem = 0
	for i in range ( 0 , N ) :
		if ( ( arr [ i ] * arr [ i ] ) % P == 1 ) :
			cntElem = cntElem + 1
	return cntElem
if __name__ == " _ _ main _ _ " :
	arr = [ 1 , 6 , 4 , 5 ]
	N = len ( arr )
	P = 7
	print ( equvInverse ( arr , N , P ) )