Advertisement
karbaev

binpow-norec

Feb 29th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.15 KB | None | 0 0
  1. int binpow (int a, int n) { //без рекурсии
  2.     int res = 1;
  3.     while (n) {
  4.         if (n & 1)
  5.             res *= a;
  6.         a *= a;
  7.         n >>= 1;
  8.     }
  9.     return res;
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement