Comment on Why does the for loop repeat in this recursion?
milon@lemm.ee 10 months agoIt’s supposed to be a pyramid but not my code. It’s an example of a recursive function from a CS50 lecture and I’m just trying to understand how the code works line by line.
xmunk@sh.itjust.works 10 months ago
So is my example of Height 3 in line with your expectations?
milon@lemm.ee 10 months ago
Yep
xmunk@sh.itjust.works 10 months ago
I wrote an equivalent version just using nested loops - reading it might help you understand why the recursion works the way it does.
milon@lemm.ee 10 months ago
Thanks. I did see that. I have a general understanding of how recursion works I think where the function calls itself again and again but I don’t get why the code (for loop) below the draw(n - 1) is recursive.