Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/chaharnishant11/CodeIn10DSA
/ power
Function
power
Recursion/Code/powerOf2.cpp:7–14 ·
view source on GitHub ↗
Source
from the content-addressed store, hash-verified
5
using namespace std;
6
7
int power(int n){
8
if (n==1){ //Base Case
9
return 2;
10
}
11
else{
12
return 2*power(n-1); //multiplication with 2 is small calculation & power(n-1) is the recursive call
13
}
14
}
15
16
int main() {
17
int n;
Callers
1
main
Function · 0.70
Calls
no outgoing calls
Tested by
no test coverage detected