n must be odd at this point . So we can skip one element ( Note i = i + 2 )
for ( $ i = 3 ; $ i <= sqrt ( $ n ) ; $ i = $ i + 2 ) { if ( $ n % $ i == 0 ) { $ count ++ ; while ( $ n % $ i == 0 ) $ n = $ n / $ i ; } }