Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
Really the question you need to ask yourself is, "will recursion actually save me time/space for this problem?"
Recursion in most languages involves saving a set of details onto a call stack, then once we've gotten to the base case, popping them all off the stack one-by-one and applying any remaining logic.
A mental picture could be sending a package through mail, only for n number of addresses saying, "oh, this isn't your final destination. Here: go to this address instead." Eventually, the right address gets the package, but then simply scribbles a note on the box and ships it back to the last address that sent the box to it! This then daisy-chains its way back to the post office, before its done.
Recursion is a neat tool in programming, but often times its way more efficient to not go through the hoops of a postal service-esque solution if you know in advance what optimizations you can make space/process-wise to get your solution.
Depends on language, whether it has TCO or not, for this kata recursion isn't doable for js, ruby, python, if done correctly should work for elixir.
Edit: Don't know about rust.
Recursion isn't a good idea here.