Count of the non | Java 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
import java . util . * ; class GFG { static Vector < Integer > getFactorization ( int x ) { int count = 0 ; Vector < Integer > v = new Vector < > ( ) ; while ( x % 2 == 0 ) { count ++ ; x = x / 2 ; } if ( count != 0 ) v . add ( count ) ; for ( int i = 3 ; i <= Math . sqrt ( x ) ; i += 2 ) { count = 0 ; while ( x % i == 0 ) { count ++ ; x /= i ; } if ( count != 0 ) v . add ( count ) ; } if ( x > 1 ) { v . add ( 1 ) ; } return v ; } static int nonPrimeDivisors ( int N ) { Vector < Integer > v = getFactorization ( N ) ; int ret = 1 ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) ret = ret * ( v . get ( i ) + 1 ) ; ret = ret - v . size ( ) ; return ret ; } public static void main ( String [ ] args ) { int N = 8 ; System . out . println ( nonPrimeDivisors ( N ) ) ; } }