12345678910111213141516171819202122
  1. import java.util.Scanner;
  2. /**
  3. * Created by iyasuwatts on 10/17/17.
  4. */
  5. public class Main {
  6. public static void main(String[] args){
  7. Scanner keyboard = new Scanner(System.in);
  8. System.out.println("Enter a valid integer number.");
  9. int n = keyboard.nextInt();
  10. int sum = 0;
  11. for(int i = 1; i <= n; i++)
  12. {
  13. sum += i;
  14. }
  15. System.out.println("The sum of the numbers 1 to " + n + " is " + sum);
  16. }
  17. }