count the number for each prime factor
for ( int i = 3 ; i <= Math . sqrt ( n ) ; i += 2 ) { while ( n % i == 0 ) { n = n / i ; if ( count . containsKey ( i ) ) { count . put ( i , count . get ( i ) + 1 ) ; } else { count . put ( i , 1 ) ; } } } if ( n > 2 ) { if ( count . containsKey ( n ) ) { count . put ( n , count . get ( n ) + 1 ) ; } else { count . put ( n , 1 ) ; } } int flag = 0 ; for ( Map . Entry < Integer , Integer > b : count . entrySet ( ) ) {