import java.util.Scanner;
public class sum{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		System.out.print("Enter n: ");
		int n = scanner.nextInt();
		System.out.print("Enter m: ");
		int m = scanner.nextInt();
		int sum = 0;
			for(int i = 0; i<=n; i++){

				for(int j = i+1; j<=n; j++){
					sum = i * j;
				}
			}
		System.out.print("Sum is: "+sum);
	}
}

I'm not sure if this gives out the correct answer.

try the code out for yourself, and do some manual computations, and it would be also nice if you are going to debug/ trace your program rather than Asking people here :D

it will give the correct answer, for some definition of "correct answer".

Lmao yes i have tried this code, done manual computations, etc :D haha and no i'm not asking for answers as usual :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.