Check whether count of odd and even factors of a number are equal | Function to check condition ; Initialize even_count and od_count ; Loop runs till square root ; Driver Code
function isEqualFactors ( N ) { let ev_count = 0 , od_count = 0 ; for ( let i = 1 ; i <= Math . sqrt ( N ) + 1 ; i ++ ) { if ( N % i == 0 ) { if ( i == N / i ) { if ( i % 2 == 0 ) ev_count += 1 ; else od_count += 1 ; } else { if ( i % 2 == 0 ) ev_count += 1 ; else od_count += 1 ; if ( ( N / i ) % 2 == 0 ) ev_count += 1 ; else od_count += 1 ; } } } if ( ev_count == od_count ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ; } let N = 10 ; isEqualFactors ( N ) ;