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.
How does the solution have to call a more complicated function? sum() is not more complicated than your solution--it eventually resolves to a while loop that simply loops over the iterable, accumulating the sum along the way, and then returns it. Your solution, on the other hand, recursively calls itself n-1 times, setting up a new stack frame each time, and consuming n frames on the stack, which is resource-intensive in both time and space. Your solution isn't even tail recursive, so tail call optimization cannot be used to reduce these costs.