Skip to content

Instantly share code, notes, and snippets.

@manojnaidu619
Created June 20, 2019 13:29
Show Gist options
  • Save manojnaidu619/d325406ca4a7372d64db0cae0f5c9c12 to your computer and use it in GitHub Desktop.
Save manojnaidu619/d325406ca4a7372d64db0cae0f5c9c12 to your computer and use it in GitHub Desktop.
Exponents using Recursion in CPP
#include <iostream>
using namespace std;
int power(int m, int n){
if(n==0){ return 1;}else{
return power(m,n-1) * m;
}
}
int main(){
cout << power(2,4) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment