12345678910111213141516171819202122 |
- /**
- * Created by Thuy Khong.
- */
-
- import java.util.Scanner;
- public class Main {
-
- public static void main(String[] args){
- Scanner scan = new Scanner(System.in);
- System.out.println("Please enter a number.");
- int number = scan.nextInt();
- int sum = 0;
-
- for (int i = 0; i<= number; i++) {
- sum = sum + i;
- }
- System.out.println("The sum of the numbers 1 to " + number + " is " + sum);
- }
- }
-
-
|