Optimization of power by modulo function.