12345678910111213141516171819202122 |
- import java.util.Scanner;
-
- /**
- * Created by iyasuwatts on 10/17/17.
- */
- public class Main {
-
- public static void main(String[] args){
- Scanner keyboard = new Scanner(System.in);
- System.out.println("Enter a valid integer number.");
- int n = keyboard.nextInt();
-
- int sum = 0;
- for(int i = 1; i <= n; i++)
- {
- sum += i;
- }
-
- System.out.println("The sum of the numbers 1 to " + n + " is " + sum);
- }
- }
|