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.
The code below the draw(n - 1) isn’t recursive… the call to draw(n - 1) is the recursion.
Sometimes, it can be helpful to invert recursion. Think about what draw(0) would be and write it down… then compute draw(1) using the value you previously computed for draw(0).
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.
xmunk@sh.itjust.works 10 months ago
The code below the
draw(n - 1)
isn’t recursive… the call todraw(n - 1)
is the recursion.Sometimes, it can be helpful to invert recursion. Think about what draw(0) would be and write it down… then compute draw(1) using the value you previously computed for draw(0).