Created
June 20, 2019 13:29
-
-
Save manojnaidu619/d325406ca4a7372d64db0cae0f5c9c12 to your computer and use it in GitHub Desktop.
Exponents using Recursion in CPP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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