u/Plenty_Whereas4459

Sum of multiples formula - am I crazy?

Using prep swift, the formula recommended for sum of multiples in an interval requires you to first determine if all multiples will be paired, and then apply one of the below:

- (# of pairs * sum of an interval pair)

- (# of pairs * sum of an interval pair) + (unpaired middle integer / 2)

I find this kind of tedious and a little confusing. I return the same results if I apply the below to any range:

-(# of multiples * sum of an interval pair) / 2

I’m wondering if there’s a reason I really need to get comfortable with the first approach, if my formula is off, or if other people just find the first approach more intuitive?

reddit.com
u/Plenty_Whereas4459 — 4 days ago