This is just a formula for adding up the numbers 1 to n (the order you add numbers doesn't matter).
If you have a collection of numbers that you don't know the structure to (ie, it's not something as simple as an arithmetic sequence), there's no trick to adding them up faster that's faster than doing it one by one.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey dude, great article!
I'm just missing one thing
do i have to assume this list is always sorted?
This is just a formula for adding up the numbers 1 to n (the order you add numbers doesn't matter).
If you have a collection of numbers that you don't know the structure to (ie, it's not something as simple as an arithmetic sequence), there's no trick to adding them up faster that's faster than doing it one by one.