Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int p_wrr(int a, int n)
  6. {
  7.     if (n == 0)
  8.         return 1;
  9.     if (n % 2 == 1)
  10.         return p_wrr(a,n-1)*a;
  11.     else {
  12.         int b = p_wrr(a, n/2);
  13.         return b * b;
  14.     }
  15.        
  16. }
  17.  
  18.  
  19. int main()
  20. {
  21.     int a, n;
  22.     cin >> a >> n;
  23.     cout << p_wrr(a, n);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement