write a program in Java to find and display the sum of the following series. it's urgent
Attachments:
Answers
Answered by
1
Question:-
Write a Java program to find and display the sum of the series.
S=1*2 + 2*3 + 3*4 + 4*5...
Program:-
import java.util.*;
class Sum
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the value of n: ");
int n=sc.nextInt();
int s=0;
for(int i=1;i<=n;i++)
s+=i*(i+1);
System.out.println("Sum of the Series is: "+s);
}
}
Similar questions