Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int t(int a, int n)
- {
- if(n==0)
- return 1;
- else
- if(n==1)
- return a;
- else
- if (n%2==0)
- return t(a, n/2)*t(a, n/2);
- else
- return a*t(a, n-1)
- }
- int main()
- {
- int k,p;
- cin>> k>> p;
- int rez=t(k,p);
- cout << rez;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement