Count of the non | Function to factors of the given number ; Loop to find the divisors of the number 2 ; Loop to find the divisors of the given number upto SQRT ( N ) ; Condition to check if the rest number is also a prime number ; Function to find the non - prime divisors of the given number ; Loop to count the number of the total divisors of given number ; Driver Code ; Function Call
function getFactorization ( x ) { let count = 0 ; let v = [ ] ; while ( x % 2 == 0 ) { count ++ ; x = Math . floor ( x / 2 ) ; } if ( count != 0 ) v . push ( count ) ; for ( let i = 3 ; i <= Math . floor ( Math . sqrt ( x ) ) ; i += 2 ) { count = 0 ; while ( x % i == 0 ) { count ++ ; x = Math . floor ( x / i ) ; } if ( count != 0 ) v . push ( count ) ; } if ( x > 1 ) { v . push ( 1 ) ; } return v ; } function nonPrimeDivisors ( N ) { let v = getFactorization ( N ) ; let ret = 1 ; for ( let i = 0 ; i < v . length ; i ++ ) ret = ret * ( v [ i ] + 1 ) ; ret = ret - v . length ; return ret ; } let N = 8 ; document . write ( nonPrimeDivisors ( N ) ) ;