Applying above discussed formula for every array element
int mul = 1 ; for ( int i = 0 ; i < factors [ num ] . size ( ) ; i ++ ) mul *= ( ( Math . pow ( factors [ num ] . get ( i ) . F , factors [ num ] . get ( i ) . S + 1 ) - 1 ) / ( factors [ num ] . get ( i ) . F - 1 ) ) ; return mul - num ; }