Skip to content

Commit 8124397

Browse files
authored
Update PowerOf2.java
1 parent 5cec288 commit 8124397

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Recursion/PowerOf2/PowerOf2.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ class PowerOf2 {
44

55
static int PowerOfTwo(int n){
66

7+
// base case
8+
79
if(n==0){
810
return 1;
911
}
1012

13+
// recursive relation
14+
1115
return 2*PowerOfTwo(n-1);
1216

1317
// int small_problem = PowerOfTwo(n-1);

0 commit comments

Comments
 (0)