updating value of x , g and b according to algorithm
x = ( x * pow ( g , pow ( 2 , r - m - 1 ) , p ) ) % p ; g = pow ( g , pow ( 2 , r - m ) , p ) ; b = ( b * g ) % p ; if ( b == 1 ) return x ; r = m ; } }