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
function equvInverse ( arr , N , P ) { let cntElem = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] * arr [ i ] ) % P == 1 ) { cntElem ++ ; } } return cntElem ; } let arr = [ 1 , 6 , 4 , 5 ] ; let N = arr . length ; let P = 7 ; document . write ( equvInverse ( arr , N , P ) ) ;