Computer Science, asked by tanya42383, 5 months ago

write a program to find the sum of series for the following series 1 + (1*2)+2+(1*2*3)+3+.................9+(1+2+3+.......10)​

Answers

Answered by anindyaadhikari13
4

Question:-

Write a java program to find the sum of the series.

1+(1*2)+2+(2*3)+....

Program:-

import java.util.*;

class Sum

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the number of terms: ");

int n=sc.nextInt(), s=0, p=1;

for(int i=1;i<=n;i++)

{

p=i+i*(i+1);

s+=p;

}

System.out.println("Sum of the series is: "+s);

}

}

Answered by BrainlyProgrammer
3

Answer:

int n=sc.nextInt() ;

int I, n, p=1, I;

for(I=1;I<=n;I++)

{

if((i%2)!=0)

s+=I;

else

{

p*=i;

s+=p;

}

}

Similar questions