The sum equals . This is one of the most useful formulas in competitive programming.
For example, . You get the answer without a loop.
Why does this work? Pair the first and last terms: , , and so on. You have pairs, each summing to , giving . The formula generalizes this pairing trick.