adding recursion review question
This commit is contained in:
@@ -14,8 +14,11 @@ What is the value of fun(2)?
|
|||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
int fun(int n) {
|
int fun(int n) {
|
||||||
if (n == 4) return n;
|
if (n == 4){
|
||||||
else return 2*fun(n+1);
|
return n;
|
||||||
|
} else {
|
||||||
|
return 2 * fun(n+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user