For each prime factor , calculating ( p ^ ( a + 1 ) - 1 ) / ( p - 1 ) and adding it to answer .
let ans = 1 ; for ( let [ key , value ] of mp . entries ( ) ) { let pw = 1 ; let sum = 0 ; for ( let i = value + 1 ; i >= 1 ; i -- ) { sum += ( i * pw ) ; pw = key ; } ans *= sum ; } return ans ; }