#### Sum of Series coderinme

Write Java program to compute the sum of the 2+4+6+———+10.

Mathematically, This is an an Arithmetic Sequence because we can clearly see that the difference between one term and the next is a constant (difference 2). In General we could write an arithmetic sequence like this:

{a, a+d, a+2d, a+3d, … }

where:

a is the first term, and

d is the difference between the terms (called the “common difference”)

To sum up the terms of this arithmetic sequence:

a + (a+d) + (a+2d) + (a+3d) + …

use this formula:

Sum = n/2 * { 2a + (n-1) * d }

In Java, it is quiet simple:

Program:

```
import java.io.*;
public class Q10
{
public static void main(String[] args)
{
int sum=0,i;
for(i=2;i<=10;i=i+2)
sum=sum+i;
System.out.println(" The sum is :"+sum);
}
}
```

For more programs on Java, visit our Java Archives

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme