the base mehtod is to reduce the size of the numbers

sum(3|5) = sum(3) + sum(5) - sum(15)

sum(3) = 3(1+2+...end) = 3* (1+end)*end/2

so the whole loop will be changed to just several operations