C++ recursion explained easy 😵

Поделиться
HTML-код
  • Опубликовано: 4 янв 2025

Комментарии • 10

  • @BroCodez
    @BroCodez  2 года назад +14

    #include
    int factorial(int num);
    int main () {
    std::cout 1){
    return num * factorial(num - 1);
    }
    else{
    return 1;
    }
    }

  • @Dazza_Doo
    @Dazza_Doo 2 года назад

    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?

    • @tabibhassan3376
      @tabibhassan3376 Месяц назад

      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)

  • @FrederikWollert
    @FrederikWollert 8 месяцев назад

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

  • @Tevadaa
    @Tevadaa 4 месяца назад

    Thank you bro code ur the goat fr

  • @wlsedlacek
    @wlsedlacek Год назад +1

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

    • @masterali2837
      @masterali2837 Год назад +3

      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)

  • @baddarelsherif7234
    @baddarelsherif7234 2 месяца назад

    Love u❤😊