Recursion Explained In 60 Seconds

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ม.ค. 2025

ความคิดเห็น • 281

  • @TrollPumpkins
    @TrollPumpkins ปีที่แล้ว +693

    Dude I’ve struggled with recursion since I was introduced to it a year ago and this short made more sense than my college course. Much appreciated !

    • @AdnanShaikh-zh5zd
      @AdnanShaikh-zh5zd ปีที่แล้ว +6

      Watch Kunal kushwaha recursion series. Very clear explanation

    • @opensocietyenjoyer
      @opensocietyenjoyer ปีที่แล้ว +3

      this video didn't help you learn recursion though.

    • @911Salvage
      @911Salvage 7 หลายเดือนก่อน +1

      You need that much time to grasp such a trivial basic concept? 😮

    • @curtmastor
      @curtmastor 7 หลายเดือนก่อน

      Same experience here. Recursion is pretty cool.

    • @TrollPumpkins
      @TrollPumpkins 5 หลายเดือนก่อน +3

      @@911Salvagea surface level understanding that helped me complete coursework is different than feeling connected to the underlying principle! everyone processes info differently my friend

  • @BriariusTitan
    @BriariusTitan ปีที่แล้ว +65

    you know what man, you put so much effort into your videos with the edits and research and clear explanations, you deserve more views. im sure it's just a matter of time until you blow up, your vids are very good fr

    • @ConnerArdman
      @ConnerArdman  ปีที่แล้ว +7

      Thanks! Glad you enjoy them 😀

  • @Zandercraft
    @Zandercraft 7 หลายเดือนก่อน +90

    One problem with this approach, aside from a potential stack overflow as others have mentioned, could be:
    1. _Use a high-level language_
    2. _Enter very large number_
    3. _Program hits max recursion depth or overflows stack_

    • @chickenbobbobba
      @chickenbobbobba 5 หลายเดือนก่อน +3

      youll most likely reach 64 bit integer limit before then

    • @Zandercraft
      @Zandercraft 5 หลายเดือนก่อน +1

      @@chickenbobbobba A lot of languages cap max recursion depth a lot lower.

    • @chickenbobbobba
      @chickenbobbobba 5 หลายเดือนก่อน

      @@Zandercraft im sure it can handle 20 recursion layers. thats not a lot, comparatively.

    • @maxencegitton377
      @maxencegitton377 4 หลายเดือนก่อน

      You can do recursion in assembly easily. I don't understand the first point

    • @Zandercraft
      @Zandercraft 4 หลายเดือนก่อน

      @@maxencegitton377 A lot of high-level languages have an artificially low max recursion depth (E.g., Python).

  • @HuntingKingYT
    @HuntingKingYT ปีที่แล้ว +10

    A function is called with three steps:
    1. Push to the stack where to return after the function
    2. Go to the function's beginning
    3. When the function returns, it basically takes the return location out of the stack and goes to it
    PS if you have a recursive function with only one place of it calling itself, then you can always turn it into a loop. So with a few tricks you can convert the recursive version of Fibonacci to the loop version, just if you make it with linear complexity

  • @joopie46614
    @joopie46614 ปีที่แล้ว +91

    I would say avoid recursion like the plague, it can cause stack overflows and it's also slow since you're making so many function calls which depend on each other and making many stack frames, only use it if its better than alternatives for example when iterating trees.

    • @ChatGPT-IV
      @ChatGPT-IV 7 หลายเดือนก่อน +5

      Finally somebody who coded his own function in asm. But recursion makes the code cleaner, and more readable in my opinion.

    • @69k_gold
      @69k_gold 7 หลายเดือนก่อน +4

      Agree, it should only be used if there's an intuitive sub-problem and an unintuitive/impossible iterative alternative

    • @b3arwithm3
      @b3arwithm3 7 หลายเดือนก่อน +1

      It makes the coder look smart though.

    • @thenecroyeti1
      @thenecroyeti1 7 หลายเดือนก่อน +3

      A lot of functional languages have tail-call-optimization, so it won't continuously create stack frames for each recursive call. JS was supposed to have this years ago, but not sure it ever got implemented.

    • @natescode
      @natescode 7 หลายเดือนก่อน +1

      Use a real language that has tail call optimization.

  • @Devplaygrounds
    @Devplaygrounds 7 หลายเดือนก่อน +22

    You forgot about the edge case when n == 0. Because you can send 0 in the first call 0! = 1

    • @libor_ca
      @libor_ca 6 หลายเดือนก่อน +2

      And negatives I think, you should make the return statement not work after factoring 0, such as making a Boolean if trigger

    • @armandcaringi
      @armandcaringi 6 หลายเดือนก่อน +4

      It’s not an edge case, you just set the base case to 0! = 1, then 1! = 1 * 0! = 1

    • @leonschubert2453
      @leonschubert2453 5 หลายเดือนก่อน

      @@armandcaringi is correct. Just replace the 1 with a 0 and you're good to go.

    • @daniel.affonso
      @daniel.affonso 4 หลายเดือนก่อน +1

      I think the guy is just talking about recursion. The factorial is an example, not the focus

    • @sonnyhe2002
      @sonnyhe2002 2 หลายเดือนก่อน

      ​@armandcaringi what do you mean, he did forget 0! in his explanation.

  • @KaushalDhruw
    @KaushalDhruw ปีที่แล้ว +2

    This is your best video so far.

  • @Krokodil986
    @Krokodil986 ปีที่แล้ว +22

    Wow, what a clean explanation, good work man 💯

  • @vuanhkhoa9715
    @vuanhkhoa9715 ปีที่แล้ว +106

    Recursion make life easier. But only solve problem with recursion if you cant find a way to do it in an iterative way

    • @khelix5017
      @khelix5017 ปีที่แล้ว +10

      sometimes the recursive way is even more efficient than the iterative

    • @luizfilif
      @luizfilif ปีที่แล้ว +6

      but you can always solve the problem iteratively, just create a stack and push what you need there. However, there are langs ​​that do this for you, so using recursion instead of using iteration ends up being the same thing in certain languages

    • @tofaa3668
      @tofaa3668 ปีที่แล้ว +12

      ​@khelix5017 this is literally never the case, function calls are slower than iteration

    • @prathamrathore776
      @prathamrathore776 7 หลายเดือนก่อน +2

      how the hell can you do backtracking problems iteratively

    • @vuanhkhoa9715
      @vuanhkhoa9715 7 หลายเดือนก่อน

      @@prathamrathore776 take an example about the fibonacci number problem. This problem itself actually has 3 ways to solve: recursive, recursive with memoizaiton and dynamic programming approach. And that DP approach is how we solve that problem in an iterative way. I've solved a lot of these problem and the recursive solution is always the easiest solution to come up with

  • @Crytic_Music
    @Crytic_Music 2 หลายเดือนก่อน

    One improvement in this cse assuming this is in the context of a interpreted language: make the base case n

  • @kenth407
    @kenth407 4 หลายเดือนก่อน

    Wow... You just help me get that right easily. Thanks!

  • @Dira_1111
    @Dira_1111 ปีที่แล้ว +1

    U just a earned subscriber , I used to struggle understanding recursion thanks for this animations and explanation

  • @williamsezenwa9542
    @williamsezenwa9542 3 หลายเดือนก่อน

    Thanks alot was struggling with this

  • @JustPassingByHere
    @JustPassingByHere 7 หลายเดือนก่อน +1

    Very clear and concise explanation! Keep up the good work!

  • @armanyusuf
    @armanyusuf ปีที่แล้ว

    Used this method in my Python practical, multipled N*I in a for loop and it worked

  • @yarnu221
    @yarnu221 4 หลายเดือนก่อน

    Thank you this was very neat

  • @abhijitganji9509
    @abhijitganji9509 7 หลายเดือนก่อน

    Man tqsm, always been confused with recursion u made it very clear and simple. You earned a subcriber✌️👍

  • @nexsynthzer_beatbox253
    @nexsynthzer_beatbox253 ปีที่แล้ว

    Wow, even phd professors in our colleges don’t have the talent to teach us like that..!! I already subscribed because i am impressed by your skills, looking forward to your videos giving us free knowledge, insights and skills..

  • @WifeWantsAWizard
    @WifeWantsAWizard 6 หลายเดือนก่อน +5

    func recursionIsDangerous(n):
    if n < 0:
    return -1 # an error code
    if n < 2:
    return 1
    # let's say n = 5
    p = n # p = 5
    product = n # product = 5
    count = 0
    while (p > 2):
    # 1 and 0 are done
    p -= 1 # p becomes 4 - 3 - 2
    count += 1
    product *= p # product is (5*4), (20*3), and (60*2)
    if count > 1000:
    # always break an out-of-control self-running function
    print("runaway loop detected in recursionIsDangerous()")
    break
    return product # returns 120

  • @Makebuildmodify
    @Makebuildmodify 6 หลายเดือนก่อน

    subbed. I think you can use 2 as the base case.

  • @davep8221
    @davep8221 5 หลายเดือนก่อน

    I had a professor who said, "if you don't have a conditional in your recursive function, it's probably a bug."
    You have to be sure you write the function properly.
    n * factorial(n - 1) vs factorial(n - 1) * n can have wildly different run times, depending on the language and compiler/interpreter.

  • @thegreatest2222
    @thegreatest2222 7 หลายเดือนก่อน

    Best explanation I’ve seen

  • @ShadowmyrGames
    @ShadowmyrGames 5 หลายเดือนก่อน

    A downside to consider is that, in contrast to a loop, recursion does increase the stacksize of the program and may cause stackoverflow errors if the recursive chain becomes too large. Im addition recursive functions are often harder to read and debug, so in general its better to just use a loop if possible.

  • @ChibuikeObojiofor
    @ChibuikeObojiofor 7 หลายเดือนก่อน

    This the best explanation

  • @griffin955
    @griffin955 6 หลายเดือนก่อน

    My understanding of any loop or recursive piece of code is that you must always provide the program a way to escape out of the loop. That's the only rule.

  • @daviduntalan
    @daviduntalan 6 หลายเดือนก่อน

    explained perfectly!

  • @ShiloBuff
    @ShiloBuff ปีที่แล้ว +5

    And then someone tries factorial(0) or less and hits an infinite loop. There's multiple ways to better handle this. For instance I usually do

    • @GoldbergToastyBred
      @GoldbergToastyBred ปีที่แล้ว

      and also i think instead of clearing old output it just stacks over so if u make really big number i think you can get stack overflow

  • @nepmythgaming
    @nepmythgaming 5 หลายเดือนก่อน

    My teacher couldn't teach it in 40 min and you did it in 60 second

  • @the_infinity_snake
    @the_infinity_snake ปีที่แล้ว +1

    This is still very mind-f***** ,
    there's gotta be a good understandable way to explain this strange mechanic of a function that calls itself...
    🤔
    I'll wanna see a video with an explaination like that, both intuitively and technically.
    (My English is terrible, hope that i made myself clear... 😅)

  • @MrChhetri
    @MrChhetri 4 หลายเดือนก่อน

    You earned a subscriber.

  • @austincodes
    @austincodes 7 หลายเดือนก่อน

    Bro is teaching FP in JS. This is basically how a do while loop works for people who take a more imperative programming approach

  • @putuadibrata
    @putuadibrata ปีที่แล้ว

    Bro, thx for the tips. As a person that is bad at math. This really help. Thx. Make more math content. 😅

  • @furyphychogaming1682
    @furyphychogaming1682 7 หลายเดือนก่อน

    bro rizzed in 60 secs(including me ) subscribing

  • @jackoberto01
    @jackoberto01 ปีที่แล้ว

    There are very few real life scenarios I've had where recursion is better than loops though of course there are exceptions.
    Usually the examples that are used to explain it would run faster without it.

  • @razorxxxiv5884
    @razorxxxiv5884 ปีที่แล้ว

    Just for good looks:
    const factorial = (n) => (n===1 ? 1 : factorial(n-1))

    • @vadlacharan5442
      @vadlacharan5442 ปีที่แล้ว

      Do you think negative numbers have factorials

  • @fishcadet
    @fishcadet ปีที่แล้ว

    Thank you.

  • @coolmanthecool603
    @coolmanthecool603 7 หลายเดือนก่อน +1

    just do
    function factorial(n):
    return (n

  • @faBi_292
    @faBi_292 ปีที่แล้ว

    good explanation

  • @nlk_97
    @nlk_97 7 หลายเดือนก่อน

    Yep that is indeed recursion, but I think that some people may still be confused because they don't know that all the function calls are stored on a stack and that's why it can then go back and recursively solve all of the function calls right back until the original function call...

  • @crosstalk125
    @crosstalk125 6 หลายเดือนก่อน +1

    Return 1?

  • @tienthanh21697
    @tienthanh21697 ปีที่แล้ว

    Holy crap. I can understand it so easily. Thanks 😂

  • @Jarikraider
    @Jarikraider 5 หลายเดือนก่อน +1

    His base case fails when someone puts 0 in or a negative number in assuming the type is signed.

  • @adeniyitaofik3832
    @adeniyitaofik3832 4 หลายเดือนก่อน

    immediately subscribed

  • @yeetskeet691
    @yeetskeet691 ปีที่แล้ว

    return n == 1 and n or n * factorial(n-1)

  • @AnanthulasVamshi
    @AnanthulasVamshi 4 หลายเดือนก่อน

    Smooth got 1 subscriber ❤

  • @Migler1
    @Migler1 3 หลายเดือนก่อน

    Base case, aka a guard clause.

  • @d_dstroyer0445
    @d_dstroyer0445 ปีที่แล้ว

    I just studied it, but I don't understand why I would ever use it.
    For small numbers like 5 the difference is unnoticeable, but for bigger ones recursion takes way more time and free space than any loop.

    • @luizfilif
      @luizfilif ปีที่แล้ว +1

      hey, clarifying your question, indeed this happens in the most langs, i guess. However, certain langs have something called tail-call optimization. I recommend you search this term for more informations if you want it. And keep in mind there's not a situation where you are obligated to use recursions, you can always create a stack by yourself and push just you need, instead stacking an entire function in the heap on each call

  • @ojtheaviator1795
    @ojtheaviator1795 7 หลายเดือนก่อน

    You missed an opportunity to make this shorts video loop in a seemingly recursive manner!

  • @abdelrahmanuth8130
    @abdelrahmanuth8130 6 หลายเดือนก่อน

    What if n < 1 ? You have to put every cases

  • @koftabalady
    @koftabalady ปีที่แล้ว +6

    function factorial(n) {
    return n * ((n == 0) ? 1 : factorial(n - 1));
    }

  • @OnyxGetsDubs
    @OnyxGetsDubs 7 หลายเดือนก่อน

    no one has ever explained recursion this simple

  • @krishnasensei
    @krishnasensei ปีที่แล้ว +3

    I am a beginner why would we use recursion over a loop

    • @ConnerArdman
      @ConnerArdman  ปีที่แล้ว +1

      It's just another option to have. Certain problems just lend themselves to the recursive solutions being much simpler. For example, many tree traversal algorithms are _way_ easier to implement recursively and also easier to read.

  • @InfernoTsugikuni
    @InfernoTsugikuni 4 หลายเดือนก่อน

    did i get myselt mixed up in a js course? man im not learning that abomination any time soon

  • @Scoltren
    @Scoltren ปีที่แล้ว +9

    It should be (n

  • @stopcensoringmen5044
    @stopcensoringmen5044 7 หลายเดือนก่อน

    I'm subscribing now.

  • @watcherquek263
    @watcherquek263 ปีที่แล้ว

    20 seconds: 1) have an initial function, 2) the recursive step that breaks the problem down and 3)terminating condition. There

  • @FaisalAlali1
    @FaisalAlali1 ปีที่แล้ว +3

    I wounder what would happen if I put -1 in the function :)

    • @bikramjeetdasgupta
      @bikramjeetdasgupta ปีที่แล้ว

      That’s the finest thing u don’t

    • @zico6892
      @zico6892 ปีที่แล้ว

      -1! Is not a thing

    • @Revoltition
      @Revoltition ปีที่แล้ว +1

      ​@@zico6892in this case it's possible and it will keep multiplying it by itself subtracted by one and stopped because of stack overflow, this is why I'd like to use

  • @emmanuelolaniyi5704
    @emmanuelolaniyi5704 4 หลายเดือนก่อน

    broo respect

  • @user-iu1xg6jv6e
    @user-iu1xg6jv6e 5 หลายเดือนก่อน

    Try factorial(0) or any negative number

  • @JohnWarosa999
    @JohnWarosa999 ปีที่แล้ว +2

    why the need for THREE equal signs?

    • @_.luminosity._
      @_.luminosity._ ปีที่แล้ว

      to prevent type conversion

    • @JohnWarosa999
      @JohnWarosa999 ปีที่แล้ว +1

      no clue what that is @@_.luminosity._ but ok

  • @birbobserver612
    @birbobserver612 หลายเดือนก่อน

    Why did he put a triple = sign instead of just double = at the base case?

  • @makar_ts
    @makar_ts 7 หลายเดือนก่อน +3

    recursion limit: hello

  • @valcubeto
    @valcubeto ปีที่แล้ว

    Please, check "impossible" cases, like n being zero or a negative number. Check if n < 2 in this case

    • @myrstad_
      @myrstad_ ปีที่แล้ว

      Fun fact, 0! Is 1. But yeah definitely check for negatives

    • @zico6892
      @zico6892 ปีที่แล้ว

      Also it can be negative, just not a negative integer

  • @Machtyn
    @Machtyn 6 หลายเดือนก่อน

    Please don't use n === x when doing recursion or any test that measures an upper or lower bound. Who knows if that number suddenly increase or decreases past your limiting factor.

  • @H4KnSL4K
    @H4KnSL4K 2 หลายเดือนก่อน

    BUG! What if you try factorial(-1)? It might eventually finish if you're usuing an integer type that 'rolls over' once it gets large enough...

  • @alexteles9968
    @alexteles9968 7 หลายเดือนก่อน

    One thing i never understood is how the input number in this case for example decreases after each call, like if i input 5 how does calling itself replaces 5 with 4 without needing another input (i know it returns n-1 but still, usually a function doesnt save previous input), i may sound dumb right now.

  • @raffymcfee9846
    @raffymcfee9846 4 หลายเดือนก่อน

    Whats the purpose of recursion for?

  • @fightinginsight
    @fightinginsight 7 หลายเดือนก่อน

    This is the easiest example of recursion

  • @botprzemek
    @botprzemek ปีที่แล้ว +1

    Making few projects in C I've seen that often recursion is 5 to 10x slower than iteration, but why?

    • @ConnerArdman
      @ConnerArdman  ปีที่แล้ว +1

      Asymptotically, recursive solutions are usually the same (except for occasional extra space used on the call stack). Practically, it can be a tad slower in some cases, although I don’t think I’ve ever seen 5-10x slower, at least for anything taking a meaningful amount of time. This just comes from the extra complexity of a function call vs a loop, there’s just more assembly instructions generated.
      That said, compilers are really smart. A well optimized compiler will oftentimes produce the exact same output or nearly the exact same output for many simpler recursive solutions such as those using tail recursion.

    • @jakobgebler2759
      @jakobgebler2759 ปีที่แล้ว

      This realy depends. Condionals like the if in the clip can realy slow down compared to no conditions like in the iterative solution because of pipelining...but true, a good compiler care about this

  • @michelecafagna1755
    @michelecafagna1755 ปีที่แล้ว

    Nice explanation but the two codes work different:
    The first one is fine, even if it shouldn't be funny putting a negative number there😂 (but I know it was just an example so ok)
    The second one instead doesn't work even where the factorial is defined.
    It should be:
    if (n===0) {
    return 1
    } ecc.

  • @ibrahmjasim
    @ibrahmjasim 7 หลายเดือนก่อน

    Wow. im wandering if the time complexity is the same as a simple loop with if condition.

    • @ConnerArdman
      @ConnerArdman  7 หลายเดือนก่อน +1

      Time complexity is the same. Although recursion oftentimes has a worse space complexity due to space taken on the call stack (but this can in many cases be mitigated with techniques like tail recursion).

    • @ibrahmjasim
      @ibrahmjasim 7 หลายเดือนก่อน

      @@ConnerArdman oh , i get it now . thx

  • @nezhioevangelion4982
    @nezhioevangelion4982 7 หลายเดือนก่อน

    Is "i =+ 1" also recursive?

  • @doomse150
    @doomse150 7 หลายเดือนก่อน

    Technically, the base case should be n == 0 with 0! being 1 as well.

  • @H4KnSL4K
    @H4KnSL4K 2 หลายเดือนก่อน

    I'm pretty sure this is the exact same explanation you get from any programming related class. You might need a few more example cases to understand it better. Plus, some understanding of what it does to the 'stack' and why it's not always the best idea.

  • @antoniomiguelcapelramirez5248
    @antoniomiguelcapelramirez5248 6 หลายเดือนก่อน

    I like it!

  • @rsvdark_main
    @rsvdark_main ปีที่แล้ว

    I get that it's just an example but this would break if you input any non positive number or any non integer value

  • @priyanshukumarsah2746
    @priyanshukumarsah2746 5 หลายเดือนก่อน

    What if n = 0 , this code will throw segmentation fault due to stack overflow.

  • @afonsoferreira5835
    @afonsoferreira5835 ปีที่แล้ว

    Just a question. Why use recursion instead of using a loop?

    • @rony86
      @rony86 ปีที่แล้ว

      to implement divide and conquer philosophy...

  • @oolmfoxz8170
    @oolmfoxz8170 7 หลายเดือนก่อน

    generaly, if u can, avoid recurtif function.... it's lot of lot slower than for-loop

  • @schofer1556
    @schofer1556 ปีที่แล้ว

    When i learned recursion it was easier to me to write recursive functions than normal lmao

  • @sumirandahal76
    @sumirandahal76 ปีที่แล้ว

    Conner loves JavaScript. 😮

  • @iamtheboneofmysword728
    @iamtheboneofmysword728 7 หลายเดือนก่อน

    I literally cant wrap my head around recursive functions

  • @mannnie55
    @mannnie55 6 หลายเดือนก่อน

    how did i understand this in just under a minute

  • @JediMediator
    @JediMediator 8 หลายเดือนก่อน

    Fun fact, there are some problems that can only be solved recursively, and not iteratively. Ackerman's function is one example.

    • @ConnerArdman
      @ConnerArdman  8 หลายเดือนก่อน +3

      This is not true. The proof that any recursive function can be written iteratively is actually fairly straightforward. Essentially you just implement a call stack manually and process it iteratively.
      The ackermann function is not primitive recursive. This means it cannot be implemented with only for loops of predetermined size. However, using constructs of “complete” modern languages it can be implemented iteratively (although it is way more complicated than doing it recursively).

    • @JediMediator
      @JediMediator 8 หลายเดือนก่อน

      @@ConnerArdman today I learned, thanks!

  • @AnimePokerTX
    @AnimePokerTX 5 หลายเดือนก่อน

    Oooo…high risk recursion! What if you pass a decimal or a negative number in your factorial function?

  • @veddy1674
    @veddy1674 5 หลายเดือนก่อน

    function factorial(n) {
    return (n == 1) ? n : factorial(n-1);
    }

    • @Kirisame_Soup
      @Kirisame_Soup 5 หลายเดือนก่อน

      factorial(0)

    • @TOZA
      @TOZA 4 หลายเดือนก่อน

  • @astroide-fs9uf
    @astroide-fs9uf 7 หลายเดือนก่อน

    What what are the three === because i usually do == . Or this is not the language i think it is?

    • @AwesomeEv
      @AwesomeEv 7 หลายเดือนก่อน

      === means strict equals, which checks for value and type. For this example i would use == instead, since n should always be a number.

  • @tarsislimadev
    @tarsislimadev ปีที่แล้ว

    it is because every recursive function must to have an itself call and a condition to stop.

  • @stevenli5258
    @stevenli5258 7 หลายเดือนก่อน

    Got this reel to late, A month after my AP CSA exam😢😢😢

  • @jakobgebler2759
    @jakobgebler2759 ปีที่แล้ว

    I this case the for loop is much fast because of the condition

  • @nytr
    @nytr ปีที่แล้ว

    Its better to use for loop for that but yeah.

  • @olsayd
    @olsayd ปีที่แล้ว +52

    if n == 0 would be more accurate

    • @ConnerArdman
      @ConnerArdman  ปีที่แล้ว +11

      Fair enough, been a minute since I took a math class lol 😅

    • @olsayd
      @olsayd ปีที่แล้ว +2

      @@ConnerArdmangreat video either way

    • @nytr
      @nytr ปีที่แล้ว

      Well you'd return 0 and the return value would be 0 * n! which is wrong

    • @coredeadman5980
      @coredeadman5980 ปีที่แล้ว +5

      ​@@nytr No 0! = 1. Thats what he meant. Theoreticaly the function needs to be called until 0! is the last factorial.

    • @nytr
      @nytr ปีที่แล้ว +1

      @@coredeadman5980 yeah you're right, sorry :D

  • @seanmcghee2373
    @seanmcghee2373 ปีที่แล้ว

    As a "curly brace on the next line" guy I'm saddened by this. I get recursion. I don't get this curly brace penchant. Yeah, I've heard the "it's more readable" and "it saves real estate". No on the first and not nearly enough to make a difference (change the font size) on the second.

    • @andrry_armor
      @andrry_armor ปีที่แล้ว

      It's a language convention. JS uses this, C++/C# uses curly braces on new lines, python uses indentation (the latter case, however, is not a convention but a strict language rule).

  • @kazykamakaze131
    @kazykamakaze131 7 หลายเดือนก่อน

    Be careful with recursions, they have the capability of dropping your server if badly written since some recursions can become quite complex in real world and if not well thought through or tested, will 100% place your job on the line when you drop an entire companies operations.

  • @emmanuelcueva2430
    @emmanuelcueva2430 ปีที่แล้ว

    So it’s just a different way to loop? And can’t I just use a while/do loop instead or how wrong am I?

    • @andrry_armor
      @andrry_armor ปีที่แล้ว

      Nope. You can branch recursion calls, unlike the loop. You can call 4 recursions in one function, for example, to find a shortest path on a rectangular plane with barriers.

  • @shortForPychael
    @shortForPychael ปีที่แล้ว

    This is some dangerous code here, should be checking n

  • @Bruno.Madrical.3698
    @Bruno.Madrical.3698 ปีที่แล้ว

    is it java ?

  • @shalevforfor5550
    @shalevforfor5550 5 หลายเดือนก่อน

    That kinda easy and useful but I can't see myself using it in other things then math

  • @Sencifouy
    @Sencifouy 7 หลายเดือนก่อน

    What's factorial(-6) gonna give me?

  • @bottlecapbeaver
    @bottlecapbeaver 5 หลายเดือนก่อน

    Why three equal signs