Calculating powers of prime factors and storing them in a map mp [ ] .
let mp = new Map ( ) ; for ( let j = 2 ; j <= Math . sqrt ( n ) ; j ++ ) { let count = 0 ; while ( n % j == 0 ) { n = Math . floor ( n / j ) ; count ++ ; } if ( count != 0 ) mp . set ( j , count ) ; }