Ad
  • Custom User Avatar

    Yes - recursions are fascinating, however, be careful with them. Recursions could be double-edged swords...
    Consider that each recursion level costs in memory on the stack. So if you have too many levels (self invocation) you would end up with a crash on lack of memory (or slowing down your whole computer as your code exhausts whole of the available memory).
    In this specific case it is probably fine - we assume a number with a reasonable number of digits.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution