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
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
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
Math,
2 months ago
English,
2 months ago
English,
5 months ago
Social Sciences,
10 months ago
Physics,
10 months ago
India Languages,
10 months ago