1234567891011121314
  1. import java.util.*;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner input = new Scanner(System.in);
  5. System.out.println("Enter a number: ");
  6. int userNum = input.nextInt();
  7. int addNum = 0;
  8. for (int i = 1; i <= userNum; i++) {
  9. addNum = addNum + i;
  10. }
  11. System.out.println(addNum);
  12. }
  13. }