Fast power function


Fast Power function in this code is not working.

int fastPower(int a, int b) //This fn takes O(log base2 b) time
{
    if(b == 0) return 1;
    ll smallPower = fastPower(a , b/2)*fastPower(a , b/2);
    if(b&1)
    return a*smallPower;
    return smallPower;
}

is the desired code for calculating fast power