Today I was writing some recursive code and it behaved in a very weird way and I couldn't find out why this happened,
Here is the code
It gives runtime error, and doesn't assign the values correctly!
However if I do it like this
Everything just works perfectly! I feel I'm missing something but I couldn't figure it out for over half an hour and yet the code is simple (I suppose).
It would be greatly appreciated if anyone could point out the problem.