To avoid Stack Over flow, could you do this: Half way into Recursion, you then exit the function by passing on the information into a new Function (that does the exact same thing) - I would assume that the STACK would clear itself of the first Recursion and be on it's merry way, then you hand the "Batton" (relay running race) back to the Original function and start the cycle all over again?
well you're in a for loop. so the steps will decrease every time. Basically you're iterating but not manually rather calling the main function. (sorry for late answer)
well yes then 99 becomes 98 then 97 and soo on until 0 then it does not run the if statement anymore and breaks out of the functions (this is pretty simple to understand im just guessing your first programing experience is with c++ but i recemend python for starting)
#include
int factorial(int num);
int main () {
std::cout 1){
return num * factorial(num - 1);
}
else{
return 1;
}
}
To avoid Stack Over flow, could you do this: Half way into Recursion, you then exit the function by passing on the information into a new Function (that does the exact same thing) - I would assume that the STACK would clear itself of the first Recursion and be on it's merry way, then you hand the "Batton" (relay running race) back to the Original function and start the cycle all over again?
well you're in a for loop. so the steps will decrease every time. Basically you're iterating but not manually rather calling the main function. (sorry for late answer)
Awesome Video. Is it not necessary to have a faster and memory efficient Program in sorting and Searching Algorithm programs?
Thank you bro code ur the goat fr
how is the (steps - 1) stopping the result from going into loop? isnt (steps -1) just =99 ?
well yes then 99 becomes 98 then 97 and soo on until 0 then it does not run the if statement anymore and breaks out of the functions (this is pretty simple to understand im just guessing your first programing experience is with c++ but i recemend python for starting)
Love u❤😊