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.
nice
Euclid would be proud of you :D
i did this
since his sum is already declared 0, it will return 0 if list is empty.
Since sum is declared as 0, in case of an empty list it returns 0. Or am i mistaken?
This is what I think the author was looking for, though you might be missing the part about returning 0 if the list is empty.
I knew it must be some mathematical trick.
Yes, you are right. I was just overthinking. In fact, I am shamelessly using this method in other katas now. Thanks!
It's not a big deal. The numbers would have to be ginormous, certainly far larger than the test cases in this kata, for the recursive gcd to use significant stack depth.
Will this solution not increase the maximal recursion depth to obtain the solution?
damn boi, that's clever af
my self esteem after seeing these 1 line solutions be like "not stonks".
The maximal recursion depth is limited by JavaScript engine. We can rely on it being 10000, some engines allow more, but 100000 is probably out of limit for the majority of them. There are automatic optimizations that help alleviate this (“tail calls optimizations”), but they are not yet supported everywhere and work only in simple cases.
That's true! Thank you!
pure magic that you do not need to look for the minimum value
Loading more items...