Skip to content

Instantly share code, notes, and snippets.

@kovrov
Created March 4, 2012 23:22
Show Gist options
  • Save kovrov/1975347 to your computer and use it in GitHub Desktop.
Save kovrov/1975347 to your computer and use it in GitHub Desktop.
pow_r
int64_t pow_r(int64_t a, int64_t b)
{
if (b == 0)
return 1;
if (b == 1)
return a;
int64_t res = pow_r(a, b/2);
res *= res;
if (b % 2)
res *= a;
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment