It’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.
Comment on Why does the for loop repeat in this recursion?
xmunk@sh.itjust.works 10 months ago
So you’re drawing a triangle of #
that starts skinny in the top left and grows to the right with a height and width of n
?
As an example, Height 3 would be:
# ## ###
I’m not following your questions, but the code seems pretty reasonable.
milon@lemm.ee 10 months ago
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.
xmunk@sh.itjust.works 10 months ago
An example using a nested loop
3v4l.org/e0IJm