Skip to content

Instantly share code, notes, and snippets.

@ruan4261
Created November 20, 2020 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruan4261/edb1160041adec4af0edb94299313652 to your computer and use it in GitHub Desktop.
Save ruan4261/edb1160041adec4af0edb94299313652 to your computer and use it in GitHub Desktop.
// 不能输入负数参数
long binaryPow(long base, long exponent) {
long res = 1;
while (exponent > 0) {
if ((exponent & 1) == 1) res *= base;
base *= base;
exponent >>= 1;
}
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment