Computer Science, asked by bunnyverma580, 1 year ago

write an algorithm to add first 15 even positive integers

Answers

Answered by faraanahmedhashmi
1

good morning mate..

we can write an algorithm using AP.

here no.of terms n=15

first term a=2

common difference d=2.

now .

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

Sn=n/2(4+2n-2)

Sn=n/2(2n-2)

taking 2 as common we get.

Sn=n(n-1)

thus we get an algorithm to find the sum of first 15 even numbrrs.

now lets check.

n=15

S15=15(15-1)

S15=15×14

S15=210

this is a correct answer.

hence our algorithm is correct.

Similar questions