Computer Science, asked by raistar0, 6 months ago

1.
Wap to calculate the sum of even numbers from 20 to 40?​

Answers

Answered by Anonymous
0

Answer:

Ap = 22 , 24 , 26 ..... 38

  • d = 2

  • a = 22

an = a + (n -1)d

38 = 22 + (n - 1)2

16 = 2n - 2

2n = 18

  • n = 9

Sn = n/2(2a + (n-1)d)

Sn = 9/2(44 + 16)

Sn = 9/2(60)

Sn = 9 × 30

Sn = 270

Answered by esccba28
0
sum =0;
for i from 20 to 40
If i%2 == 0
sum += i;
End if
End for
return sum;
Similar questions