123456789101112131415161718192021222324252627282930313233343536 |
-
-
-
- /**
- * Created by iyasuwatts on 10/17/17.
- */
- import java.util.*;
- public class Main {
- private static int num;
-
- public Main(int n){
-
- }
-
- /*public static int getN(){
- return n;
- }
-
- public static void setN(int a){
- n=a;
- } */
-
- public static void main(String[] args){
-
- //setN(0);
- Scanner input = new Scanner(System.in);
- System.out.println("Please enter a number");
- int num = input.nextInt();
- int sum = 0;
- for(int i = num; i>=1; i--){
- sum += i;
- }
- System.out.println("sum of 1 to " + num + " is " + sum);
- }
- }
|