32. Write a program to input 'n'. Find and print the sum of the following series upto 'n' terms:
S = 1 + (1 + 2) + (1 + 2 + 3) + (1 + 2 + 3 + 4) + ............ + n terms.write this program in java language
Answers
Answered by
4
Hope it helps you!!!!
Mark as brainliest!!!!!
Attachments:
Answered by
4
Answer:
import java.util.Scanner;
class Sum {
public static void main(String[ ] args) {
System.out.print("Input number = ");
int n = new Scanner(System.in).nextInt();
int sum = 0;
for(int i=1; i<=n; i++) {
for(int j=1; j<=i; j++)
sum += j;
}
System.out.println("Sum = "+sum);
}
}
Hope it helps!
By the way, it was a good program .
Mark me brainliest.
Similar questions