Skip to content

Instantly share code, notes, and snippets.

@surinoel
Last active July 16, 2019 00:58
Show Gist options
  • Save surinoel/c21a476227f2d881ce8775aaa75d7a26 to your computer and use it in GitHub Desktop.
Save surinoel/c21a476227f2d881ce8775aaa75d7a26 to your computer and use it in GitHub Desktop.
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