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)
4 Respuestas
+ 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
+ 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.😶😶
0
Hey Brains, does this mean that you could (hypothetically) create your own loop, without using a predefined loop keyword?