Evals

mail@pastecode.io avatar
unknown
java
2 months ago
581 B
5
Indexable
Never
import java.util.Scanner;

public class EvalOne {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        System.out.print("Enter the value of N: ");
        int N = scanner.nextInt();
        
        int sum = 0;
        for (int i = 1; i <= N; i++) {
            int innerSum = 0;
            for (int j = 1; j <= i; j++) {
                innerSum += j;
            }
            sum += innerSum;
        }
        
        sum = -sum;
        System.out.println("The value of y is: " + sum);
    }
}
Leave a Comment