Find all the prime factors and their powers
while ( N > 1 ) { N /= s [ N ] ; if ( N != 0 && s [ N ] != 0 ) if ( ! cnt . containsKey ( s [ N ] ) ) cnt . put ( s [ N ] , 1 ) ; else cnt . put ( s [ N ] , cnt . get ( s [ N ] ) + 1 ) ; } if ( cnt . containsKey ( 0 ) ) cnt . remove ( 0 ) ; int totfactor = 1 ; for ( Map . Entry < Integer , Integer > i : cnt . entrySet ( ) ) totfactor *= i . getValue ( ) + 1 ;