You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int myPow2(int n) // returns 2^n, calculated in integer math
{
int result = 1;
if (n = 0) return result;
else if ( n < 0) return -1;
else if (n > 30) return -1; //overflow
else
{
for (int i = 0; i < n; i++) result = result *2;
return result;
}
}
Suggestion to use custom function: