fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int power(int base, int exp){
  5. int res= 1;
  6. while(exp >0){
  7. if(exp %2 == 1) res *= base;
  8. else base *= base;
  9. exp /= 2;
  10. }
  11. return res;
  12. }
  13.  
  14. int main(){
  15. cout << power(2,5);
  16. }
Success #stdin #stdout 0.01s 5300KB
stdin
Standard input is empty
stdout
8