Power

 

#include <bits/stdc++.h>
using namespace std ;

int pow(int x, int n){
//Base case
if (n==0) return 1;
//Recursive case
int smallAns = pow( x,n-1);
//Calculation
return x*smallAns ;
}

int main(){
int x ;
cin >> x ;
int n ;
cin >> n ;
cout << pow(x,n) ;

}

Comments

Popular posts from this blog

CodeChef::CSUB

How Recursion Works?

CodeChef::TREE2