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.
don't use var declaration in forloop or functions please, use let instead
This is straight forward and insightful.
Что если введут 100000, код будет перебирать каждое число ? Максимально не эффективно
O(n) is good, but you can go in steps of 15 until you get close enough for O((n/15)+6.5) (on average) :)
return sum = 0 by default then
This comment is hidden because it contains spoiler information about the solution
So simple, yet so nice.
I think for code redability point of view should place if condition to return 0 for case of negative number.
filter returns a new array and doesn't mutate the argument.
Learn to match! The code works in O(n), this is a naive solution. If the input data value is greater than 10 ^10, the code will work very slowly (or even not at all). Using the sum of the arithmetic progression gives a constant time complexity. I don't understand why so many people marked such a decision as "the best".
This comment is hidden because it contains spoiler information about the solution
This solution is at least 10 years old.
Great,concise code! However we're not in 2014 anymore so there is no need for 'var' anymore besides some extreme edge cases.
it's exactly what ChatGPT gaves me when i asked him to reduce my code and make it more concise lol
Hiho why is this solution correct? If in the text was also a condition for 3 and 5 and also for negative values, all of these is not tested...
Loading more items...