Last active
July 16, 2019 00:58
-
-
Save surinoel/c21a476227f2d881ce8775aaa75d7a26 to your computer and use it in GitHub Desktop.
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
long long multiplier(long long a, long long b) { | |
if(b == 0) { | |
return 1; | |
} | |
else if(b == 1) { | |
return b; | |
} | |
if(b % 2 == 0) { | |
long long tmp = multiplier(a, b/2); | |
return tmp * tmp; | |
} | |
else { | |
return a * multiplier(a, b-1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment