Skip to content

Instantly share code, notes, and snippets.

@kohnakagawa
Last active December 28, 2015 08:09
Show Gist options
  • Save kohnakagawa/7469775 to your computer and use it in GitHub Desktop.
Save kohnakagawa/7469775 to your computer and use it in GitHub Desktop.
template<typename T>
T pow_n(T x, int n){
T a = 1.0;
while(n > 0){
if(n % 2 == 0){
x = x*x;
n = n>>1;
}else{
a = a*x;
n--;
}
}
return a;
}
@kohnakagawa
Copy link
Author

fastest calculation power

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment