Check if count of divisors is even or odd | Function to count the divisors ; Initialize count of divisors ; Note that this loop runs till square root ; If divisors are equal increment count by one Otherwise increment count by 2 ; Driver Code
< ? php function countDivisors ( $ n ) { $ count = 0 ; for ( $ i = 1 ; $ i <= sqrt ( $ n ) + 1 ; $ i ++ ) { if ( $ n % $ i == 0 ) $ count += ( $ n / $ i == $ i ) ? 1 : 2 ; } if ( $ count % 2 == 0 ) echo " Even STRNEWLINE " ; else echo " Odd STRNEWLINE " ; } echo " The ▁ count ▁ of ▁ divisor : ▁ " ; countDivisors ( 10 ) ; ? >