If i is a factors then increase the frequency of i
while ( N % i == 0 ) { if ( Map . containsKey ( i ) ) Map . put ( i , Map . get ( i ) + 1 ) ; else Map . put ( i , 1 ) ; N /= i ; } } if ( N > 2 ) { if ( Map . containsKey ( N ) ) Map . put ( N , Map . get ( N ) + 1 ) ; else Map . put ( N , 1 ) ; } }