KnowledgeBoat Logo

Computer Applications

Write a program to find the sum of the given series:

S = 1 + (1*2) + (1*2*3) + --------- to 10 terms.

Java

Java Nested for Loops

ICSE

37 Likes

Answer

public class KboatSeriesSum
{
    public static void main(String args[]) {
        int sum = 0;
        for (int i = 1; i <= 10; i++) {
            int p = 1;
            for (int j = 1; j <= i; j++)
                p *= j;
            sum += p;
        }
        System.out.println("Sum = " + sum);
    }
}

Output

BlueJ output of Write a program to find the sum of the given series: S = 1 + (1*2) + (1*2*3) + --------- to 10 terms.

Answered By

18 Likes


Related Questions