0
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.

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by NexG
0

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

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.