Recursion | Sololearn: Learn to code for FREE!



To use information from the last operation, I have to use recursion , but I don’t understand how to. I’m trying to modify a nested array, I have to change an element , but don’t want to have to do something like “arr[0][0][0][0].changeValue()”

11/1/2019 6:26:47 PM

Jamie Charles

3 Answers

New Answer


That is not how recursion works. Recursion is used when you have a big problem and the solution to it is a smaller problem and this goes on. For eg take the factorial problem, to find 5's factorial you need a 4's factorial and to find a 4's factorial you need a 3's factorial and so on. So I don't think you can use it in your code for nested arrays.


Can you give little more detail about what your recursive function need to do ? If your purpose is to use previous information, then probably there is no need of recursion but if you still want then you can make function with arguments as array(unmodified), index value of element you want to change & new value with return type as array(return modified array & then use it as unmodified array in next call).


i actually figured out what i was suppose to do and is similar to what you suggested!