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.
This is a very clever way of adding the multiples of 3 and 5 without repeating the common multiple. However I can't mark it as a best practice because it forces a traverse through all of the natural number (minus 1). If we're talking about a small input number it's negligeble, but if we're talking about a very high input number then it starts to take a toll.
i had no idea what i was doing and no way could have figured this out. thanks for reminding me im far from mastering 7 kyu
nice!
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.
Loading more items...