Write a program that asks the user for a number n and prints the sum of the numbers 1 to n.
public class Main {
public static void main(String[] args) {
var scanner = new java.util.Scanner(System.in);
System.out.print("What is n? ");
int n = scanner.nextInt();
int sum = 0;
for (int i = 1; i <= n; ++i) {
sum += i;
}
System.out.println("The sum of 1..n is " + sum);
}
}