0

How recursive functions really work!

Everywhere I look the(easy) example for recursive function turns out to be factorial finder. Yes, i know that recursive functions call themselves for eternity if there isn't any base case. But even in SL lesson it isn't explained very well how it works. If someone would explain it I would really appreciate it. (Web links are welcome too)

16th May 2018, 6:49 PM
Akib
Akib - avatar
4 Respostas
+ 6
#1: function do(){ #2: alert("hi"); #3: do(); #4: } #5 do(); When the do function is called on line 5 its innercontents are run. on line2 the function alerts(); on line3 the function calls do again(itself) and alerts and calls do...and this goes on forever
16th May 2018, 7:09 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 1
Brains Can you explain how factorial finder works? That's what i need to know. I said i know what recursion/recursive function is. Just didn't understand how the program worked when base case returned 1.😶😶
18th May 2018, 5:22 AM
Akib
Akib - avatar
0
Hey Brains, does this mean that you could (hypothetically) create your own loop, without using a predefined loop keyword?
16th May 2018, 8:18 PM
Your Friend
Your Friend - avatar