Main.java 439B

12345678910111213141516171819202122
  1. /**
  2. * Created by iyasuwatts on 10/17/17.
  3. */
  4. import java.util.Scanner;
  5. public class Main {
  6. public static void main(String[] args){
  7. Scanner scan = new Scanner(System.in);
  8. System.out.println("Enter a number: ");
  9. int input = scan.nextInt();
  10. int result = 0;
  11. for (int i = 0; i <= input; i++) {
  12. result += i;
  13. }
  14. System.out.println("Your answer is: " + result);
  15. }
  16. }