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 [ i ] = count [ i ] + 1 ; } else { count . Add ( i , 1 ) ; } } } if ( n > 2 ) { if ( count . ContainsKey ( n ) ) { count [ n ] = count [ n ] + 1 ; } else { count . Add ( n , 1 ) ; } } int flag = 0 ; foreach ( KeyValuePair < int , int > b in count ) {