Count of distinct power of prime factor of N | Function to count the number of distinct positive power of prime factor of integer N ; Iterate for all prime factor ; If it is a prime factor , count the total number of times it divides n . ; Find the Number of distinct possible positive numbers ; Return the final count ; Given Number N ; Function Call
function countFac ( n ) { var m = n ; var count = 0 ; for ( var i = 2 ; ( i * i ) <= m ; ++ i ) { var total = 0 ; while ( n % i == 0 ) { n /= i ; ++ total ; } var temp = 0 ; for ( var j = 1 ; ( temp + j ) <= total ; ++ j ) { temp += j ; ++ count ; } } if ( n != 1 ) ++ count ; return count ; } var N = 24 ; document . write ( countFac ( N ) ) ;