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.
beacuse "sum" is reserved name for sum function. and we cant use reserved names if follow PEP8 rules.
why is sum not okay?
O(n) is good, but you can do better
see my solution :)
Maybe that's a C echoing in the authors head :)
I thought the same, but than I tested and noticed that if you input a negative number to the range function, it gives you always a 0. So the code also considers negative numbers
negative numbers are not considered in this code
approve
I don't think the parenthesis around the modulos are serving any purpose here. They can be removed
too long, and do not use "sum" for name of variable
nice!!!
since it is used as a variable I think it doesn't pose any problems here. But I still agree that this is not a good practice
I agree w/ @sine that a variable named 'sum' isn't wise. That withstanding, my solution was the same. This solution consistently runs about a half second faster than the higher voted one-liner with input of 100,000,000, and I'd argue it is easier to read.
here you redefine the sum() built-in function, which is usually a bad practice