Advertisement
Mihai_Preda

Untitled

Feb 25th, 2021
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.18 KB | None | 0 0
  1. int power(int base, int exp)
  2. {
  3.     if(exp == 0)
  4.         return 1;
  5.     if(exp % 2 == 0)
  6.         return base * base * power(base, exp/2);
  7.     return base * power(base, exp-1);
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement