Find the total number of composite factor for a given number | Function to return the count of prime factors of n ; Initialise array with 0 ; Stored i value into an array ; Every non - zero value at a [ i ] denotes that i is a factor of n ; Find if i is prime ; If i is a factor of n and i is not prime ; Driver code
def composite_factors ( n ) : NEW_LINE INDENT count = 0 ; NEW_LINE a = [ 0 ] * ( n + 1 ) ; NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT a [ i ] = i ; NEW_LINE DEDENT DEDENT for i in range ( 2 , n + 1 ) : NEW_LINE INDENT j = 2 ; NEW_LINE p = 1 ; NEW_LINE while ( j < a [ i ] ) : NEW_LINE INDENT if ( a [ i ] % j == 0 ) : NEW_LINE INDENT p = 0 ; NEW_LINE break ; NEW_LINE DEDENT j += 1 ; NEW_LINE DEDENT if ( p == 0 and a [ i ] != 0 ) : NEW_LINE INDENT count += 1 ; NEW_LINE DEDENT DEDENT return count ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 100 ; NEW_LINE print ( composite_factors ( n ) ) ; NEW_LINE DEDENT