Created
July 17, 2014 06:09
-
-
Save rgrig/9ab076b294fe838f088d to your computer and use it in GitHub Desktop.
This file contains 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
int power(int x, unsigned int y) { | |
if (y == 0) return 1; | |
if (y == 2) return x * x; | |
if (y&1) return x * power(power(x, y/2),2); | |
return power(power(x, y/2),2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
there are better ways ...