0
Recursion
How to get this answer? int go(int x) { if (x<1) return x; else return x + go(x-1); } What is go(6)? //answer 6
2 Respuestas
+ 4
recursive functions can be treated similar to loops
in above case the function is repeatedly calling itself till the value of i is >=1
therefore the function is called i times,
so,
we can simply explain it as:
6+go(6-1)
6+5+go(5-1)
...
6+5+4+3+2+1
= 21
0
Sara Yamaguchi Please attach the code with programming language tag