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