How to sum all odd numbers in range?

431 Views Asked by At

How easy sum all odd numbers in range?

As instance: 25 + 27 + 29 + 31?

Which formula I should apply?

2

There are 2 best solutions below

8
On BEST ANSWER

Since you indicated in comments you know how to sum the first $n$ odd numbers ($n^2$):

$25+27+29+31=$

$(1+3+5+7+9+11+13+15+17+19+21+23+25+27+29+31)-$

$(1+3+5+7+9+11+13+15+17+19+21+23)=$

$ 16^2-12^2=(16+12)(16-12)=28\times4=112$

0
On

See that

$$25+27+29+31 = 25+(25+2) + (25+4) + (25 +6)$$

$$= 4(25) + 2+4+6 = 4(25) + 2(1+2+3).$$