C++ recursion explained easy 😵

preview_player
Показать описание
#recursion #tutorial #explained

Recursion tutorial example explained
Рекомендации по теме
Комментарии
Автор

#include <iostream>
int factorial(int num);
int main () {

std::cout << factorial(10);

return 0;
}
int factorial(int num){
if(num > 1){
return num * factorial(num - 1);
}
else{
return 1;
}
}

BroCodez
Автор

Thanks i have an exam in like 2 days and needed some revision

sellex
Автор

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?

Dazza_Doo
Автор

Awesome Video. Is it not necessary to have a faster and memory efficient Program in sorting and Searching Algorithm programs?

FrederikWollert
Автор

how is the (steps - 1) stopping the result from going into loop? isnt (steps -1) just =99 ?

wlsedlacek