Iamtui1010

binpow.fun

Sep 23rd, 2022
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.21 KB | None | 0 0
  1. int binpow(int n, int m)
  2. {
  3.     if (m == 0)
  4.         return 1;
  5.     if (m == 1)
  6.         return n;
  7.     int tmp = binpow(n, m/2);
  8.     if (m % 2)
  9.         return tmp*tmp*n;
  10.     else
  11.         return tmp*tmp;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment