I'm trying to understand why am I getting the result that I am. Lets say that this is the code and result:
Sorry if this is trivial, but there isn't too many sources online about this... If the output of d(3) makes sense to me, then e(3) doesn't at all.
why does moving the write in cases like this reverse the order?
I'm guessing it has something to do with the recursion, but I'm still clueless at why.

This is because in the first case: You first write and then recursively call
d(N1), so for exampled(3)willwrite 3and thencall d(2)etc...In the second case: You first call
e(N1)and then write and this changes the order because for examplee(1)will calle(0)which will calle(-1)which will succeed and thene(0)willwrite 0thene(1)willwrite 1and so on...