Query about Question 3 from "PrepSwift: Sum of Integers in Interval" [3663]

Link: https://prepswift.gregmat.com/quizzes/quiz/prepswift-sum-of-integers-in-interval (Question 3)]
I just had a minor doubt here. Instead of following an inuitive approach like manually solving it by making 4 pairs, is there a possibility to have sort of a generalized formula for finding sum of integers [both exclusive and inclusive] that has a range different from “1 - XYZ”. Let’s say 233-764. Something of that sort. If this is present in a dedicated gregmat video, would be happy to watch it as well.

You don’t have to do it manually every time.

Generalizing the pairing idea gets you the following:

x + (x + 1) + \ldots + y = \frac{y - x + 1}{2} (x + y)
1 Like

See the video of Series 1.

1 Like

Thank you !