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.
A recursive version if not optimized at compile time generate extra assemby instruction for creating/destroying a stack context for a function call. The context contains temporary variable, caller arguments, and the return for the instruction pointer. Iterative version keeps the same stack context, no need to manage life cycle of called context, so it's faster cause less instructions to execute.
A teminal recusion can be easily optimized at compile time can be do by «de-recursivate», i.e. transform a recusive algorithm by an iterative one through the use of its own stack with a fast use of this stack. GCC do that for example.
why? Is it not good for performance?
Maybe, iterative version is easy too: https://www.codewars.com/kata/reviews/5d6ddad7e78d210001f76504/groups/5d809b2c01af06000163ed61 .
This comment is hidden because it contains spoiler information about the solution