Похожие чаты

Int pow (int x, int n){

if ( n == 1 ) return x;
if (n % 2 == 1) return pow(x,n/2,n/2) * pow(x,n/2,n/2) * x;
return pow(x,n/2,n/2) * pow(x,n/2,n/2);
}




will compiler optimzie above code to this one ?

int pow (int x, int n){
if ( n == 1 ) return x;
int temp = pow(x,n/2);
if ( n%2 == 1) return x * temp * temp;

return temp * temp ;
}

1 ответов

3 просмотра

Mostly because you are calling a function and it doesn’t know if it will alter a state

Похожие вопросы

Карта сайта