Untitled

mail@pastecode.io avatar
unknown
c_cpp
3 years ago
311 B
2
Indexable
Never
int getPower(int B,int P){

        if(P==0){
            return 1;
        }

        if(P%2==0){

            int halfPower = P/2;
            int value = getPower(B,halfPower);
            return value * value;

        }
        else{

            return B * getPower(B,P-1) ;

        }
}