DEV Community

Discussion on: Improve Your Algorithms with this Simple Equation

Collapse
 
curtisfenner profile image
Curtis Fenner

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.