Created
March 4, 2012 23:22
-
-
Save kovrov/1975347 to your computer and use it in GitHub Desktop.
pow_r
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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