Count of the non | Python3 program to find count of non - prime divisors of given number ; 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
from math import sqrt NEW_LINE def getFactorization ( x ) : NEW_LINE INDENT count = 0 NEW_LINE v = [ ] NEW_LINE while ( x % 2 == 0 ) : NEW_LINE INDENT count += 1 NEW_LINE x = x // 2 NEW_LINE DEDENT if ( count != 0 ) : NEW_LINE INDENT v . append ( count ) NEW_LINE DEDENT for i in range ( 3 , int ( sqrt ( x ) ) + 12 ) : NEW_LINE INDENT count = 0 NEW_LINE while ( x % i == 0 ) : NEW_LINE INDENT count += 1 NEW_LINE x //= i NEW_LINE DEDENT if ( count != 0 ) : NEW_LINE INDENT v . append ( count ) NEW_LINE DEDENT DEDENT if ( x > 1 ) : NEW_LINE INDENT v . append ( 1 ) NEW_LINE DEDENT return v NEW_LINE DEDENT def nonPrimeDivisors ( N ) : NEW_LINE INDENT v = getFactorization ( N ) NEW_LINE ret = 1 NEW_LINE for i in range ( len ( v ) ) : NEW_LINE INDENT ret = ret * ( v [ i ] + 1 ) NEW_LINE DEDENT ret = ret - len ( v ) NEW_LINE return ret NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 8 NEW_LINE print ( nonPrimeDivisors ( N ) ) NEW_LINE DEDENT