0
How to reduce an additional argument in recursion
Please find below code: Both the code working fine. Using stack and recursion one. Query is to eliminate the first argument of the recursive function.. can we do same thing without having additional argument called int original ? I am confused what should be base case without the original argument value ? https://code.sololearn.com/ccYvDpokBzOb/?ref=app
2 Réponses
+ 2
Recall that each program comes with a stack: the call stack. Entering a function is like .push, leaving a function is like .pop :)
void displaySeries(int n, int m) {
if (n < 0) return;
cout << n << ", ";
displaySeries(n-m, m);
cout << n << ", ";
}
0
Yeah..thanks